github.com/syumai/protoreflect@v1.7.1-0.20200810020253-2ac7e3b3a321/internal/testprotos/desc_test_complex.proto (about)

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