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