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