github.com/jhump/protoreflect@v1.16.0/desc/protoprint/testfiles/desc_test_complex-custom-sort.proto (about)

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