github.com/jhump/protoreflect@v1.16.0/desc/protoprint/testfiles/desc_test_complex-trailing-on-next-line.proto (about)

     1  syntax = "proto2";
     2  
     3  package foo.bar;
     4  
     5  option go_package = "github.com/jhump/protoreflect/internal/testprotos";
     6  
     7  import "google/protobuf/descriptor.proto";
     8  
     9  message Simple {
    10    optional string name = 1;
    11  
    12    optional uint64 id = 2;
    13  
    14    optional bytes _extra = 3;
    15    // default JSON name will be capitalized
    16  
    17    repeated bool _ = 4;
    18    // default JSON name will be empty(!)
    19  }
    20  
    21  extend google.protobuf.ExtensionRangeOptions {
    22    optional string label = 20000;
    23  }
    24  
    25  message Test {
    26    optional string foo = 1 [json_name = "|foo|"];
    27  
    28    repeated int32 array = 2;
    29  
    30    optional Simple s = 3;
    31  
    32    repeated Simple r = 4;
    33  
    34    map<string, int32> m = 5;
    35  
    36    optional bytes b = 6 [default = "\000\001\002\003\004\005\006\007fubar!"];
    37  
    38    extensions 100 to 200;
    39  
    40    extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];
    41  
    42    message Nested {
    43      extend google.protobuf.MessageOptions {
    44        optional int32 fooblez = 20003;
    45      }
    46  
    47      message _NestedNested {
    48        enum EEE {
    49          OK = 0;
    50  
    51          V1 = 1;
    52  
    53          V2 = 2;
    54  
    55          V3 = 3;
    56  
    57          V4 = 4;
    58  
    59          V5 = 5;
    60  
    61          V6 = 6;
    62        }
    63  
    64        option (fooblez) = 10101;
    65  
    66        extend Test {
    67          optional string _garblez = 100;
    68        }
    69  
    70        option (rept) = { foo: "goo", [Test.Nested._NestedNested._garblez]: "boo" };
    71  
    72        message NestedNestedNested {
    73          option (rept) = { foo: "hoo", [Test.Nested._NestedNested._garblez]: "spoo" };
    74  
    75          optional Test Test = 1;
    76        }
    77      }
    78    }
    79  }
    80  
    81  enum EnumWithReservations {
    82    X = 2;
    83  
    84    Y = 3;
    85  
    86    Z = 4;
    87  
    88    reserved 1000 to max, -2 to 1, 5 to 10, 12 to 15, 18, -5 to -3;
    89  
    90    reserved "C", "B", "A";
    91  }
    92  
    93  message MessageWithReservations {
    94    reserved 5 to 10, 12 to 15, 18, 1000 to max;
    95  
    96    reserved "A", "B", "C";
    97  }
    98  
    99  message MessageWithMap {
   100    map<string, Simple> vals = 1;
   101  }
   102  
   103  extend google.protobuf.MessageOptions {
   104    repeated Test rept = 20002;
   105  
   106    optional Test.Nested._NestedNested.EEE eee = 20010;
   107  
   108    optional Another a = 20020;
   109  
   110    optional MessageWithMap map_vals = 20030;
   111  }
   112  
   113  message Another {
   114    option (rept) = {
   115      foo: "abc",
   116      array: [ 1, 2, 3 ],
   117      s: { name: "foo", id: 123 },
   118      r: [ { name: "f" }, { name: "s" }, { id: 456 } ]
   119    };
   120    option (rept) = {
   121      foo: "def",
   122      array: [ 3, 2, 1 ],
   123      s: { name: "bar", id: 321 },
   124      r: [ { name: "g" }, { name: "s" } ]
   125    };
   126    option (rept) = { foo: "def" };
   127  
   128    option (eee) = V1;
   129  
   130    option (a) = {
   131      test: {
   132        foo: "m&m",
   133        array: [ 1, 2 ],
   134        s: { name: "yolo", id: 98765 },
   135        m: [
   136          { key: "bar", value: 200 },
   137          { key: "foo", value: 100 }
   138        ],
   139        [Test.Nested._NestedNested._garblez]: "whoah!"
   140      },
   141      fff: OK
   142    };
   143  
   144    option (map_vals) = {
   145      vals: [
   146        { key: "", value: { } },
   147        { key: "bar", value: { name: "baz" } },
   148        { key: "foo", value: { } }
   149      ]
   150    };
   151    // no key, no value
   152  
   153    optional Test test = 1;
   154  
   155    optional Test.Nested._NestedNested.EEE fff = 2 [default = V1];
   156  }
   157  
   158  message Validator {
   159    optional bool authenticated = 1;
   160  
   161    enum Action {
   162      LOGIN = 0;
   163  
   164      READ = 1;
   165  
   166      WRITE = 2;
   167    }
   168  
   169    message Permission {
   170      optional Action action = 1;
   171  
   172      optional string entity = 2;
   173    }
   174  
   175    repeated Permission permission = 2;
   176  }
   177  
   178  extend google.protobuf.MethodOptions {
   179    optional Validator validator = 12345;
   180  }
   181  
   182  service TestTestService {
   183    rpc UserAuth ( Test ) returns ( Test ) {
   184      option (validator) = {
   185        authenticated: true,
   186        permission: [ { action: LOGIN, entity: "client" } ]
   187      };
   188    }
   189  
   190    rpc Get ( Test ) returns ( Test ) {
   191      option (validator) = {
   192        authenticated: true,
   193        permission: [ { action: READ, entity: "user" } ]
   194      };
   195    }
   196  }
   197  
   198  message Rule {
   199    message StringRule {
   200      optional string pattern = 1;
   201  
   202      optional bool allow_empty = 2;
   203  
   204      optional int32 min_len = 3;
   205  
   206      optional int32 max_len = 4;
   207    }
   208  
   209    message IntRule {
   210      optional int64 min_val = 1;
   211  
   212      optional uint64 max_val = 2;
   213    }
   214  
   215    message RepeatedRule {
   216      optional bool allow_empty = 1;
   217  
   218      optional int32 min_items = 2;
   219  
   220      optional int32 max_items = 3;
   221  
   222      optional Rule items = 4;
   223    }
   224  
   225    oneof rule {
   226      StringRule string = 1;
   227  
   228      RepeatedRule repeated = 2;
   229  
   230      IntRule int = 3;
   231  
   232      group FloatRule = 4 {
   233        optional double min_val = 1;
   234  
   235        optional double max_val = 2;
   236      }
   237    }
   238  }
   239  
   240  extend google.protobuf.FieldOptions {
   241    optional Rule rules = 1234;
   242  }
   243  
   244  message IsAuthorizedReq {
   245    repeated string subjects = 1 [
   246      (rules) = {
   247        repeated: {
   248          min_items: 1,
   249          items: {
   250            string: { pattern: "^(?:(?:team:(?:local|ldap))|user):[[:alnum:]_-]+$" }
   251          }
   252        }
   253      }
   254    ];
   255  }
   256  
   257  // tests cases where field names collide with keywords
   258  
   259  message KeywordCollisions {
   260    optional bool syntax = 1;
   261  
   262    optional bool import = 2;
   263  
   264    optional bool public = 3;
   265  
   266    optional bool weak = 4;
   267  
   268    optional bool package = 5;
   269  
   270    optional string string = 6;
   271  
   272    optional bytes bytes = 7;
   273  
   274    optional int32 int32 = 8;
   275  
   276    optional int64 int64 = 9;
   277  
   278    optional uint32 uint32 = 10;
   279  
   280    optional uint64 uint64 = 11;
   281  
   282    optional sint32 sint32 = 12;
   283  
   284    optional sint64 sint64 = 13;
   285  
   286    optional fixed32 fixed32 = 14;
   287  
   288    optional fixed64 fixed64 = 15;
   289  
   290    optional sfixed32 sfixed32 = 16;
   291  
   292    optional sfixed64 sfixed64 = 17;
   293  
   294    optional bool bool = 18;
   295  
   296    optional float float = 19;
   297  
   298    optional double double = 20;
   299  
   300    optional bool optional = 21;
   301  
   302    optional bool repeated = 22;
   303  
   304    optional bool required = 23;
   305  
   306    optional bool message = 24;
   307  
   308    optional bool enum = 25;
   309  
   310    optional bool service = 26;
   311  
   312    optional bool rpc = 27;
   313  
   314    optional bool option = 28;
   315  
   316    optional bool extend = 29;
   317  
   318    optional bool extensions = 30;
   319  
   320    optional bool reserved = 31;
   321  
   322    optional bool to = 32;
   323  
   324    optional int32 true = 33;
   325  
   326    optional int32 false = 34;
   327  
   328    optional int32 default = 35;
   329  }
   330  
   331  extend google.protobuf.FieldOptions {
   332    optional bool syntax = 20001;
   333  
   334    optional bool import = 20002;
   335  
   336    optional bool public = 20003;
   337  
   338    optional bool weak = 20004;
   339  
   340    optional bool package = 20005;
   341  
   342    optional string string = 20006;
   343  
   344    optional bytes bytes = 20007;
   345  
   346    optional int32 int32 = 20008;
   347  
   348    optional int64 int64 = 20009;
   349  
   350    optional uint32 uint32 = 20010;
   351  
   352    optional uint64 uint64 = 20011;
   353  
   354    optional sint32 sint32 = 20012;
   355  
   356    optional sint64 sint64 = 20013;
   357  
   358    optional fixed32 fixed32 = 20014;
   359  
   360    optional fixed64 fixed64 = 20015;
   361  
   362    optional sfixed32 sfixed32 = 20016;
   363  
   364    optional sfixed64 sfixed64 = 20017;
   365  
   366    optional bool bool = 20018;
   367  
   368    optional float float = 20019;
   369  
   370    optional double double = 20020;
   371  
   372    optional bool optional = 20021;
   373  
   374    optional bool repeated = 20022;
   375  
   376    optional bool required = 20023;
   377  
   378    optional bool message = 20024;
   379  
   380    optional bool enum = 20025;
   381  
   382    optional bool service = 20026;
   383  
   384    optional bool rpc = 20027;
   385  
   386    optional bool option = 20028;
   387  
   388    optional bool extend = 20029;
   389  
   390    optional bool extensions = 20030;
   391  
   392    optional bool reserved = 20031;
   393  
   394    optional bool to = 20032;
   395  
   396    optional int32 true = 20033;
   397  
   398    optional int32 false = 20034;
   399  
   400    optional int32 default = 20035;
   401  
   402    optional KeywordCollisions boom = 20036;
   403  }
   404  
   405  message KeywordCollisionOptions {
   406    optional uint64 id = 1 [
   407      (syntax) = true,
   408      (import) = true,
   409      (public) = true,
   410      (weak) = true,
   411      (package) = true,
   412      (string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
   413      (bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
   414      (bool) = true,
   415      (float) = 3.140000,
   416      (double) = 3.141590,
   417      (int32) = 32,
   418      (int64) = 64,
   419      (uint32) = 3200,
   420      (uint64) = 6400,
   421      (sint32) = -32,
   422      (sint64) = -64,
   423      (fixed32) = 3232,
   424      (fixed64) = 6464,
   425      (sfixed32) = -3232,
   426      (sfixed64) = -6464,
   427      (optional) = true,
   428      (repeated) = true,
   429      (required) = true,
   430      (message) = true,
   431      (enum) = true,
   432      (service) = true,
   433      (rpc) = true,
   434      (option) = true,
   435      (extend) = true,
   436      (extensions) = true,
   437      (reserved) = true,
   438      (to) = true,
   439      (true) = 111,
   440      (false) = -111,
   441      (default) = 222
   442    ];
   443  
   444    optional string name = 2 [
   445      (boom) = {
   446        syntax: true,
   447        import: true,
   448        public: true,
   449        weak: true,
   450        package: true,
   451        string: "string",
   452        bytes: "bytes",
   453        int32: 32,
   454        int64: 64,
   455        uint32: 3200,
   456        uint64: 6400,
   457        sint32: -32,
   458        sint64: -64,
   459        fixed32: 3232,
   460        fixed64: 6464,
   461        sfixed32: -3232,
   462        sfixed64: -6464,
   463        bool: true,
   464        float: 3.140000,
   465        double: 3.141590,
   466        optional: true,
   467        repeated: true,
   468        required: true,
   469        message: true,
   470        enum: true,
   471        service: true,
   472        rpc: true,
   473        option: true,
   474        extend: true,
   475        extensions: true,
   476        reserved: true,
   477        to: true,
   478        true: 111,
   479        false: -111,
   480        default: 222
   481      }
   482    ];
   483  }