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