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