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