github.com/bakjos/protoreflect@v1.9.2/desc/protoprint/testfiles/desc_test_complex_source_info-no-trailing-comments.proto (about)

     1  syntax = "proto2";
     2  
     3  package foo.bar;
     4  
     5  import "google/protobuf/descriptor.proto";
     6  
     7  option go_package = "github.com/bakjos/protoreflect/internal/testprotos";
     8  
     9  message Simple {
    10    optional string name = 1;
    11  
    12    optional uint64 id = 2;
    13  }
    14  
    15  extend google.protobuf.ExtensionRangeOptions {
    16    optional string label = 20000;
    17  }
    18  
    19  message Test {
    20    optional string foo = 1 [json_name = "|foo|"];
    21  
    22    repeated int32 array = 2;
    23  
    24    optional Simple s = 3;
    25  
    26    repeated Simple r = 4;
    27  
    28    map<string, int32> m = 5;
    29  
    30    optional bytes b = 6 [default = "\000\001\002\003\004\005\006\007fubar!"];
    31  
    32    extensions 100 to 200;
    33  
    34    extensions 300 to 350, 500 to 550 [(label) = "jazz"];
    35  
    36    message Nested {
    37      extend google.protobuf.MessageOptions {
    38        optional int32 fooblez = 20003;
    39      }
    40  
    41      message _NestedNested {
    42        option (fooblez) = 10101;
    43  
    44        option (rept) = { foo:"goo" [foo.bar.Test.Nested._NestedNested._garblez]:"boo" };
    45  
    46        enum EEE {
    47          OK = 0;
    48  
    49          V1 = 1;
    50  
    51          V2 = 2;
    52  
    53          V3 = 3;
    54  
    55          V4 = 4;
    56  
    57          V5 = 5;
    58  
    59          V6 = 6;
    60        }
    61  
    62        extend Test {
    63          optional string _garblez = 100;
    64        }
    65  
    66        message NestedNestedNested {
    67          option (rept) = { foo:"hoo" [foo.bar.Test.Nested._NestedNested._garblez]:"spoo" };
    68  
    69          optional Test Test = 1;
    70        }
    71      }
    72    }
    73  }
    74  
    75  enum EnumWithReservations {
    76    X = 2;
    77  
    78    Y = 3;
    79  
    80    Z = 4;
    81  
    82    reserved 1000 to max, -2 to 1, 5 to 10, 12 to 15, 18, -5 to -3;
    83  
    84    reserved "C", "B", "A";
    85  }
    86  
    87  message MessageWithReservations {
    88    reserved 5 to 10, 12 to 15, 18, 1000 to max;
    89  
    90    reserved "A", "B", "C";
    91  }
    92  
    93  extend google.protobuf.MessageOptions {
    94    repeated Test rept = 20002;
    95  
    96    optional Test.Nested._NestedNested.EEE eee = 20010;
    97  
    98    optional Another a = 20020;
    99  }
   100  
   101  message Another {
   102    option (a) = { test:<foo:"m&m" array:1 array:2 s:<name:"yolo" id:98765> m:<key:"bar" value:200> m:<key:"foo" value:100>> fff:OK };
   103  
   104    option (eee) = V1;
   105  
   106    option (rept) = { foo:"abc" array:1 array:2 array:3 s:<name:"foo" id:123> r:<name:"f"> r:<name:"s"> r:<id:456> };
   107    option (rept) = { foo:"def" array:3 array:2 array:1 s:<name:"bar" id:321> r:<name:"g"> r:<name:"s"> };
   108    option (rept) = { foo:"def" };
   109  
   110    optional Test test = 1;
   111  
   112    optional Test.Nested._NestedNested.EEE fff = 2 [default = V1];
   113  }
   114  
   115  message Validator {
   116    optional bool authenticated = 1;
   117  
   118    enum Action {
   119      LOGIN = 0;
   120  
   121      READ = 1;
   122  
   123      WRITE = 2;
   124    }
   125  
   126    message Permission {
   127      optional Action action = 1;
   128  
   129      optional string entity = 2;
   130    }
   131  
   132    repeated Permission permission = 2;
   133  }
   134  
   135  extend google.protobuf.MethodOptions {
   136    optional Validator validator = 12345;
   137  }
   138  
   139  service TestTestService {
   140    rpc UserAuth ( Test ) returns ( Test ) {
   141      option (validator) = { authenticated:true permission:<action:LOGIN entity:"client"> };
   142    }
   143  
   144    rpc Get ( Test ) returns ( Test ) {
   145      option (validator) = { authenticated:true permission:<action:READ entity:"user"> };
   146    }
   147  }
   148  
   149  message Rule {
   150    message StringRule {
   151      optional string pattern = 1;
   152  
   153      optional bool allow_empty = 2;
   154  
   155      optional int32 min_len = 3;
   156  
   157      optional int32 max_len = 4;
   158    }
   159  
   160    message IntRule {
   161      optional int64 min_val = 1;
   162  
   163      optional uint64 max_val = 2;
   164    }
   165  
   166    message RepeatedRule {
   167      optional bool allow_empty = 1;
   168  
   169      optional int32 min_items = 2;
   170  
   171      optional int32 max_items = 3;
   172  
   173      optional Rule items = 4;
   174    }
   175  
   176    oneof rule {
   177      StringRule string = 1;
   178  
   179      RepeatedRule repeated = 2;
   180  
   181      IntRule int = 3;
   182    }
   183  
   184  
   185  }
   186  
   187  extend google.protobuf.FieldOptions {
   188    optional Rule rules = 1234;
   189  }
   190  
   191  message IsAuthorizedReq {
   192    repeated string subjects = 1 [(rules) = { repeated:<min_items:1 items:<string:<pattern:"^(?:(?:team:(?:local|ldap))|user):[[:alnum:]_-]+$">>> }];
   193  }
   194  
   195  // tests cases where field names collide with keywords
   196  
   197  message KeywordCollisions {
   198    optional bool syntax = 1;
   199  
   200    optional bool import = 2;
   201  
   202    optional bool public = 3;
   203  
   204    optional bool weak = 4;
   205  
   206    optional bool package = 5;
   207  
   208    optional string string = 6;
   209  
   210    optional bytes bytes = 7;
   211  
   212    optional int32 int32 = 8;
   213  
   214    optional int64 int64 = 9;
   215  
   216    optional uint32 uint32 = 10;
   217  
   218    optional uint64 uint64 = 11;
   219  
   220    optional sint32 sint32 = 12;
   221  
   222    optional sint64 sint64 = 13;
   223  
   224    optional fixed32 fixed32 = 14;
   225  
   226    optional fixed64 fixed64 = 15;
   227  
   228    optional sfixed32 sfixed32 = 16;
   229  
   230    optional sfixed64 sfixed64 = 17;
   231  
   232    optional bool bool = 18;
   233  
   234    optional float float = 19;
   235  
   236    optional double double = 20;
   237  
   238    optional bool optional = 21;
   239  
   240    optional bool repeated = 22;
   241  
   242    optional bool required = 23;
   243  
   244    optional bool message = 24;
   245  
   246    optional bool enum = 25;
   247  
   248    optional bool service = 26;
   249  
   250    optional bool rpc = 27;
   251  
   252    optional bool option = 28;
   253  
   254    optional bool extend = 29;
   255  
   256    optional bool extensions = 30;
   257  
   258    optional bool reserved = 31;
   259  
   260    optional bool to = 32;
   261  
   262    optional int32 true = 33;
   263  
   264    optional int32 false = 34;
   265  
   266    optional int32 default = 35;
   267  }
   268  
   269  extend google.protobuf.FieldOptions {
   270    optional bool syntax = 20001;
   271  
   272    optional bool import = 20002;
   273  
   274    optional bool public = 20003;
   275  
   276    optional bool weak = 20004;
   277  
   278    optional bool package = 20005;
   279  
   280    optional string string = 20006;
   281  
   282    optional bytes bytes = 20007;
   283  
   284    optional int32 int32 = 20008;
   285  
   286    optional int64 int64 = 20009;
   287  
   288    optional uint32 uint32 = 20010;
   289  
   290    optional uint64 uint64 = 20011;
   291  
   292    optional sint32 sint32 = 20012;
   293  
   294    optional sint64 sint64 = 20013;
   295  
   296    optional fixed32 fixed32 = 20014;
   297  
   298    optional fixed64 fixed64 = 20015;
   299  
   300    optional sfixed32 sfixed32 = 20016;
   301  
   302    optional sfixed64 sfixed64 = 20017;
   303  
   304    optional bool bool = 20018;
   305  
   306    optional float float = 20019;
   307  
   308    optional double double = 20020;
   309  
   310    optional bool optional = 20021;
   311  
   312    optional bool repeated = 20022;
   313  
   314    optional bool required = 20023;
   315  
   316    optional bool message = 20024;
   317  
   318    optional bool enum = 20025;
   319  
   320    optional bool service = 20026;
   321  
   322    optional bool rpc = 20027;
   323  
   324    optional bool option = 20028;
   325  
   326    optional bool extend = 20029;
   327  
   328    optional bool extensions = 20030;
   329  
   330    optional bool reserved = 20031;
   331  
   332    optional bool to = 20032;
   333  
   334    optional int32 true = 20033;
   335  
   336    optional int32 false = 20034;
   337  
   338    optional int32 default = 20035;
   339  
   340    optional KeywordCollisions boom = 20036;
   341  }
   342  
   343  message KeywordCollisionOptions {
   344    optional uint64 id = 1 [(bool) = true, (bytes) = "bytes", (default) = 222, (double) = 3.141590, (enum) = true, (extend) = true, (extensions) = true, (false) = -111, (fixed32) = 3232, (fixed64) = 6464, (float) = 3.140000, (import) = true, (int32) = 32, (int64) = 64, (message) = true, (option) = true, (optional) = true, (package) = true, (public) = true, (repeated) = true, (required) = true, (reserved) = true, (rpc) = true, (service) = true, (sfixed32) = -3232, (sfixed64) = -6464, (sint32) = -32, (sint64) = -64, (string) = "string", (syntax) = true, (to) = true, (true) = 111, (uint32) = 3200, (uint64) = 6400, (weak) = true];
   345  
   346    optional string name = 2 [(boom) = { syntax:true import:true public:true weak:true package:true string:"string" bytes:"bytes" int32:32 int64:64 uint32:3200 uint64:6400 sint32:-32 sint64:-64 fixed32:3232 fixed64:6464 sfixed32:-3232 sfixed64:-6464 bool:true float:3.14 double:3.14159 optional:true repeated:true required:true message:true enum:true service:true rpc:true option:true extend:true extensions:true reserved:true to:true true:111 false:-111 default:222 }];
   347  }