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