1syntax = "proto3";
2
3package grpc.gateway.examples.internal.proto.examplepb;
4
5import "examples/internal/proto/oneofenum/oneof_enum.proto";
6import "examples/internal/proto/pathenum/path_enum.proto";
7import "examples/internal/proto/sub/message.proto";
8import "examples/internal/proto/sub2/message.proto";
9import "google/api/annotations.proto";
10import "google/api/field_behavior.proto";
11import "google/protobuf/duration.proto";
12import "google/protobuf/empty.proto";
13import "google/protobuf/field_mask.proto";
14import "google/protobuf/timestamp.proto";
15import "google/protobuf/wrappers.proto";
16import "google/rpc/status.proto";
17import "protoc-gen-openapiv2/options/annotations.proto";
18
19option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb";
20option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
21 info: {
22 title: "A Bit of Everything";
23 version: "1.0";
24 contact: {
25 name: "gRPC-Gateway project";
26 url: "https://github.com/grpc-ecosystem/grpc-gateway";
27 email: "none@example.com";
28 };
29 license: {
30 name: "BSD 3-Clause License";
31 url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE";
32 };
33 extensions: {
34 key: "x-something-something";
35 value {string_value: "yadda"}
36 }
37 };
38 // Overwriting host entry breaks tests, so this is not done here.
39 external_docs: {
40 url: "https://github.com/grpc-ecosystem/grpc-gateway";
41 description: "More about gRPC-Gateway";
42 }
43 schemes: HTTP;
44 schemes: HTTPS;
45 schemes: WSS;
46 consumes: "application/json";
47 consumes: "application/x-foo-mime";
48 produces: "application/json";
49 produces: "application/x-foo-mime";
50 security_definitions: {
51 security: {
52 key: "BasicAuth";
53 value: {type: TYPE_BASIC}
54 }
55 security: {
56 key: "ApiKeyAuth";
57 value: {
58 type: TYPE_API_KEY;
59 in: IN_HEADER;
60 name: "X-API-Key";
61 extensions: {
62 key: "x-amazon-apigateway-authtype";
63 value {string_value: "oauth2"}
64 }
65 extensions: {
66 key: "x-amazon-apigateway-authorizer";
67 value {
68 struct_value {
69 fields {
70 key: "type";
71 value {string_value: "token"}
72 }
73 fields {
74 key: "authorizerResultTtlInSeconds";
75 value {number_value: 60}
76 }
77 }
78 }
79 }
80 }
81 }
82 security: {
83 key: "OAuth2";
84 value: {
85 type: TYPE_OAUTH2;
86 flow: FLOW_ACCESS_CODE;
87 authorization_url: "https://example.com/oauth/authorize";
88 token_url: "https://example.com/oauth/token";
89 scopes: {
90 scope: {
91 key: "read";
92 value: "Grants read access";
93 }
94 scope: {
95 key: "write";
96 value: "Grants write access";
97 }
98 scope: {
99 key: "admin";
100 value: "Grants read and write access to administrative information";
101 }
102 }
103 }
104 }
105 }
106 security: {
107 security_requirement: {
108 key: "BasicAuth";
109 value: {};
110 }
111 security_requirement: {
112 key: "ApiKeyAuth";
113 value: {};
114 }
115 }
116 security: {
117 security_requirement: {
118 key: "OAuth2";
119 value: {
120 scope: "read";
121 scope: "write";
122 }
123 }
124 security_requirement: {
125 key: "ApiKeyAuth";
126 value: {};
127 }
128 }
129 responses: {
130 key: "403";
131 value: {description: "Returned when the user does not have permission to access the resource."}
132 }
133 responses: {
134 key: "404";
135 value: {
136 description: "Returned when the resource does not exist.";
137 schema: {
138 json_schema: {type: STRING}
139 }
140 }
141 }
142 responses: {
143 key: "418";
144 value: {
145 description: "I'm a teapot.";
146 schema: {
147 json_schema: {ref: ".grpc.gateway.examples.internal.proto.examplepb.NumericEnum"}
148 }
149 }
150 }
151 responses: {
152 key: "500";
153 value: {
154 description: "Server error";
155 headers: {
156 key: "X-Correlation-Id"
157 value: {
158 description: "Unique event identifier for server requests"
159 type: "string"
160 format: "uuid"
161 default: "\"2438ac3c-37eb-4902-adef-ed16b4431030\""
162 pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$"
163 }
164 };
165 schema: {
166 json_schema: {ref: ".grpc.gateway.examples.internal.proto.examplepb.ErrorResponse"}
167 }
168 }
169 }
170 tags: {
171 name: "echo rpc"
172 description: "Echo Rpc description"
173 extensions: {
174 key: "x-traitTag";
175 value {bool_value: true}
176 }
177 }
178 extensions: {
179 key: "x-grpc-gateway-foo";
180 value {string_value: "bar"}
181 }
182 extensions: {
183 key: "x-grpc-gateway-baz-list";
184 value {
185 list_value: {
186 values: {string_value: "one"}
187 values: {bool_value: true}
188 }
189 }
190 }
191};
192
193message ErrorResponse {
194 string correlationId = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
195 pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$",
196 title: "x-correlation-id",
197 description: "Unique event identifier for server requests",
198 format: "uuid",
199 example: "\"2438ac3c-37eb-4902-adef-ed16b4431030\""
200 }];
201 ErrorObject error = 2;
202}
203
204message ErrorObject {
205 int32 code = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
206 pattern: "^[0-9]$",
207 title: "code",
208 description: "Response code",
209 format: "integer"
210 }];
211 string message = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
212 pattern: "^[a-zA-Z0-9]{1, 32}$",
213 title: "message",
214 description: "Response message"
215 }];
216}
217
218// Intentionally complicated message type to cover many features of Protobuf.
219message ABitOfEverything {
220 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
221 json_schema: {
222 title: "A bit of everything"
223 description: "Intentionally complicated message type to cover many features of Protobuf."
224 required: [
225 "uuid",
226 "int64_value",
227 "double_value",
228 "required_field_schema_json_name"
229 ]
230 extensions: {
231 key: "x-a-bit-of-everything-foo";
232 value {string_value: "bar"}
233 }
234 }
235 external_docs: {
236 url: "https://github.com/grpc-ecosystem/grpc-gateway";
237 description: "Find out more about ABitOfEverything";
238 }
239 example: "{\"int64_value\": 12, \"double_value\": 12.3}"
240 };
241
242 // Nested is nested type.
243 message Nested {
244 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {example: "{\"ok\": \"TRUE\"}"};
245 // name is nested field.
246 string name = 1;
247 uint32 amount = 2;
248 // DeepEnum is one or zero.
249 enum DeepEnum {
250 // FALSE is false.
251 FALSE = 0;
252 // TRUE is true.
253 TRUE = 1;
254 }
255
256 // DeepEnum comment.
257 DeepEnum ok = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "DeepEnum description."}];
258 }
259 Nested single_nested = 25;
260
261 string uuid = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
262 pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}",
263 min_length: 1,
264 field_configuration: {path_param_name: "uuidName"},
265 format: "uuid",
266 extensions: {
267 key: "x-internal";
268 value {bool_value: true}
269 }
270 }];
271 repeated Nested nested = 2;
272 float float_value = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
273 description: "Float value field",
274 default: "0.2",
275 required: ["float_value"]
276 }];
277 double double_value = 4;
278 int64 int64_value = 5;
279 uint64 uint64_value = 6;
280 int32 int32_value = 7;
281 fixed64 fixed64_value = 8;
282 fixed32 fixed32_value = 9;
283 bool bool_value = 10;
284 string string_value = 11;
285 bytes bytes_value = 29;
286 uint32 uint32_value = 13;
287 NumericEnum enum_value = 14;
288 pathenum.PathEnum path_enum_value = 30;
289 pathenum.MessagePathEnum.NestedPathEnum nested_path_enum_value = 31;
290 sfixed32 sfixed32_value = 15;
291 sfixed64 sfixed64_value = 16;
292 sint32 sint32_value = 17;
293 sint64 sint64_value = 18;
294 repeated string repeated_string_value = 19;
295 oneof oneof_value {
296 google.protobuf.Empty oneof_empty = 20;
297 string oneof_string = 21;
298 }
299
300 map<string, NumericEnum> map_value = 22;
301 map<string, string> mapped_string_value = 23;
302 map<string, Nested> mapped_nested_value = 24;
303
304 string nonConventionalNameValue = 26;
305
306 google.protobuf.Timestamp timestamp_value = 27;
307
308 // repeated enum value. it is comma-separated in query
309 repeated NumericEnum repeated_enum_value = 28;
310
311 // repeated numeric enum comment (This comment is overridden by the field annotation)
312 repeated NumericEnum repeated_enum_annotation = 32 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
313 title: "Repeated numeric enum title",
314 description: "Repeated numeric enum description."
315 }];
316
317 // numeric enum comment (This comment is overridden by the field annotation)
318 NumericEnum enum_value_annotation = 33 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
319 title: "Numeric enum title",
320 description: "Numeric enum description."
321 }];
322
323 // repeated string comment (This comment is overridden by the field annotation)
324 repeated string repeated_string_annotation = 34 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
325 title: "Repeated string title",
326 description: "Repeated string description."
327 }];
328
329 // repeated nested object comment (This comment is overridden by the field annotation)
330 repeated Nested repeated_nested_annotation = 35 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
331 title: "Repeated nested object title",
332 description: "Repeated nested object description."
333 }];
334
335 // nested object comments (This comment is overridden by the field annotation)
336 Nested nested_annotation = 36 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
337 title: "Nested object title",
338 description: "Nested object description."
339 }];
340
341 int64 int64_override_type = 37 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {type: INTEGER}];
342
343 // mark a field as required in Open API definition
344 string required_string_via_field_behavior_annotation = 38 [(google.api.field_behavior) = REQUIRED];
345
346 // mark a field as readonly in Open API definition
347 string output_only_string_via_field_behavior_annotation = 39 [(google.api.field_behavior) = OUTPUT_ONLY];
348
349 optional string optional_string_value = 40;
350
351 // Test openapiv2 generation of repeated fields
352 repeated string product_id = 41 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
353 pattern: "^[0-9]+$"
354 max_length: 19
355 min_length: 1
356 description: "Only digits are allowed."
357 }];
358
359 // Test openapiv2 generation of required fields with annotation and jsonschema to reproduce
360 string optional_string_field = 42;
361 string required_string_field_1 = 43 [(google.api.field_behavior) = REQUIRED];
362 string required_string_field_2 = 44 [(google.api.field_behavior) = REQUIRED];
363
364 // Test openapiv2 handling of required json_name fields
365 string required_field_behavior_json_name = 45 [
366 json_name = "required_field_behavior_json_name_custom",
367 (google.api.field_behavior) = REQUIRED
368 ];
369 string required_field_schema_json_name = 46 [json_name = "required_field_schema_json_name_custom"];
370
371 string trailing_only = 47; // Trailing only
372 string trailing_only_dot = 48; // Trailing only dot.
373 // Leading both
374 string trailing_both = 49; // Trailing both.
375 // Leading multiline
376 //
377 // This is an example of a multi-line comment.
378 string trailing_multiline = 50; // Trailing multiline.
379
380 // Specify a custom format of repeated field items
381 repeated string uuids = 51 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {format: "uuid"}];
382}
383
384// ABitOfEverythingRepeated is used to validate repeated path parameter functionality
385message ABitOfEverythingRepeated {
386 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {example: "{\"path_repeated_bool_value\": [true, true, false, true], \"path_repeated_int32_value\": [1, 2, 3]}"};
387
388 // repeated values. they are comma-separated in path
389 repeated float path_repeated_float_value = 1;
390 repeated double path_repeated_double_value = 2;
391 repeated int64 path_repeated_int64_value = 3;
392 repeated uint64 path_repeated_uint64_value = 4;
393 repeated int32 path_repeated_int32_value = 5;
394 repeated fixed64 path_repeated_fixed64_value = 6;
395 repeated fixed32 path_repeated_fixed32_value = 7;
396 repeated bool path_repeated_bool_value = 8;
397 repeated string path_repeated_string_value = 9;
398 repeated bytes path_repeated_bytes_value = 10;
399 repeated uint32 path_repeated_uint32_value = 11;
400 repeated NumericEnum path_repeated_enum_value = 12;
401 repeated sfixed32 path_repeated_sfixed32_value = 13;
402 repeated sfixed64 path_repeated_sfixed64_value = 14;
403 repeated sint32 path_repeated_sint32_value = 15;
404 repeated sint64 path_repeated_sint64_value = 16;
405}
406
407message CheckStatusResponse {
408 google.rpc.Status status = 1;
409}
410
411message Body {
412 string name = 1;
413}
414
415message MessageWithBody {
416 string id = 1;
417 Body data = 2;
418}
419
420// NumericEnum is one or zero.
421enum NumericEnum {
422 // ZERO means 0
423 ZERO = 0;
424 // ONE means 1
425 ONE = 1;
426}
427
428// UpdateV2Request request for update includes the message and the update mask
429message UpdateV2Request {
430 ABitOfEverything abe = 1;
431 // The paths to update.
432 google.protobuf.FieldMask update_mask = 2;
433}
434
435// An example resource type from AIP-123 used to test the behavior described in
436// the CreateBookRequest message.
437//
438// See: https://google.aip.dev/123
439message Book {
440 // The resource name of the book.
441 //
442 // Format: `publishers/{publisher}/books/{book}`
443 //
444 // Example: `publishers/1257894000000000000/books/my-book`
445 string name = 1;
446
447 // Output only. The book's ID.
448 string id = 2;
449
450 // Output only. Creation time of the book.
451 google.protobuf.Timestamp create_time = 3;
452}
453
454// A standard Create message from AIP-133 with a user-specified ID.
455// The user-specified ID (the `book_id` field in this example) must become a
456// query parameter in the OpenAPI spec.
457//
458// See: https://google.aip.dev/133#user-specified-ids
459message CreateBookRequest {
460 // The publisher in which to create the book.
461 //
462 // Format: `publishers/{publisher}`
463 //
464 // Example: `publishers/1257894000000000000`
465 string parent = 1;
466
467 // The book to create.
468 Book book = 2;
469
470 // The ID to use for the book.
471 //
472 // This must start with an alphanumeric character.
473 string book_id = 3;
474}
475
476// A standard Update message from AIP-134
477//
478// See: https://google.aip.dev/134#request-message
479message UpdateBookRequest {
480 // The book to update.
481 //
482 // The book's `name` field is used to identify the book to be updated.
483 // Format: publishers/{publisher}/books/{book}
484 Book book = 1 [(google.api.field_behavior) = REQUIRED];
485
486 // The list of fields to be updated.
487 google.protobuf.FieldMask update_mask = 2;
488
489 // If set to true, and the book is not found, a new book will be created.
490 // In this situation, `update_mask` is ignored.
491 bool allow_missing = 3;
492}
493
494// ABitOfEverything service is used to validate that APIs with complicated
495// proto messages and URL templates are still processed correctly.
496service ABitOfEverythingService {
497 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
498 name: "ABitOfEverything"
499 description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!"
500 external_docs: {
501 url: "https://github.com/grpc-ecosystem/grpc-gateway";
502 description: "Find out more about EchoService";
503 }
504 };
505
506 // Create a new ABitOfEverything
507 //
508 // This API creates a new ABitOfEverything
509 rpc Create(ABitOfEverything) returns (ABitOfEverything) {
510 option (google.api.http) = {post: "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}/{enum_value}/{path_enum_value}/{nested_path_enum_value}/{enum_value_annotation}"};
511 }
512 rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) {
513 option (google.api.http) = {
514 post: "/v1/example/a_bit_of_everything"
515 body: "*"
516 };
517 }
518 // Create a book.
519 rpc CreateBook(CreateBookRequest) returns (Book) {
520 option (google.api.http) = {
521 post: "/v1/{parent=publishers/*}/books"
522 body: "book"
523 };
524 }
525 rpc UpdateBook(UpdateBookRequest) returns (Book) {
526 option (google.api.http) = {
527 patch: "/v1/{book.name=publishers/*/books/*}"
528 body: "book"
529 };
530 }
531 rpc Lookup(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (ABitOfEverything) {
532 option (google.api.http) = {get: "/v1/example/a_bit_of_everything/{uuid}"};
533 }
534 rpc Custom(ABitOfEverything) returns (ABitOfEverything) {
535 option (google.api.http) = {post: "/v1/example/a_bit_of_everything/{uuid}:custom"};
536 }
537 rpc DoubleColon(ABitOfEverything) returns (ABitOfEverything) {
538 option (google.api.http) = {post: "/v1/example/a_bit_of_everything/{uuid}:custom:custom"};
539 }
540 rpc Update(ABitOfEverything) returns (google.protobuf.Empty) {
541 option (google.api.http) = {
542 put: "/v1/example/a_bit_of_everything/{uuid}"
543 body: "*"
544 };
545 }
546 rpc UpdateV2(UpdateV2Request) returns (google.protobuf.Empty) {
547 option (google.api.http) = {
548 put: "/v2/example/a_bit_of_everything/{abe.uuid}"
549 body: "abe"
550 additional_bindings: [
551 {
552 patch: "/v2/example/a_bit_of_everything/{abe.uuid}"
553 body: "abe"
554 },
555 {
556 patch: "/v2a/example/a_bit_of_everything/{abe.uuid}"
557 body: "*"
558 }
559 ]
560 };
561 }
562
563 rpc Delete(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (google.protobuf.Empty) {
564 option (google.api.http) = {delete: "/v1/example/a_bit_of_everything/{uuid}"};
565 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
566 security: {
567 security_requirement: {
568 key: "ApiKeyAuth";
569 value: {}
570 }
571 security_requirement: {
572 key: "OAuth2";
573 value: {
574 scope: "read";
575 scope: "write";
576 }
577 }
578 }
579 extensions: {
580 key: "x-irreversible";
581 value {bool_value: true}
582 }
583 };
584 }
585 rpc GetQuery(ABitOfEverything) returns (google.protobuf.Empty) {
586 option (google.api.http) = {get: "/v1/example/a_bit_of_everything/query/{uuid}"};
587 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
588 deprecated: true // For testing purposes.
589 external_docs: {
590 url: "https://github.com/grpc-ecosystem/grpc-gateway";
591 description: "Find out more about GetQuery";
592 }
593 security: {}
594 };
595 }
596 rpc GetRepeatedQuery(ABitOfEverythingRepeated) returns (ABitOfEverythingRepeated) {
597 option (google.api.http) = {get: "/v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value}"};
598 }
599 // Echo allows posting a StringMessage value.
600 //
601 // It also exposes multiple bindings.
602 //
603 // This makes it useful when validating that the OpenAPI v2 API
604 // description exposes documentation correctly on all paths
605 // defined as additional_bindings in the proto.
606 rpc Echo(grpc.gateway.examples.internal.proto.sub.StringMessage) returns (grpc.gateway.examples.internal.proto.sub.StringMessage) {
607 option (google.api.http) = {
608 get: "/v1/example/a_bit_of_everything/echo/{value}"
609 additional_bindings {
610 post: "/v2/example/echo"
611 body: "value"
612 }
613 additional_bindings {get: "/v2/example/echo"}
614 };
615 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
616 description: "Description Echo";
617 summary: "Summary: Echo rpc";
618 tags: "echo rpc";
619 external_docs: {
620 url: "https://github.com/grpc-ecosystem/grpc-gateway";
621 description: "Find out more Echo";
622 }
623 responses: {
624 key: "200"
625 value: {
626 examples: {
627 key: "application/json"
628 value: "{\"value\": \"the input value\"}"
629 }
630 }
631 }
632 responses: {
633 key: "503";
634 value: {
635 description: "Returned when the resource is temporarily unavailable.";
636 extensions: {
637 key: "x-number";
638 value {number_value: 100}
639 }
640 }
641 }
642 responses: {
643 // Overwrites global definition.
644 key: "404";
645 value: {
646 description: "Returned when the resource does not exist.";
647 schema: {
648 json_schema: {type: INTEGER}
649 }
650 }
651 }
652 };
653 }
654 rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) {
655 option (google.api.http) = {
656 post: "/v1/example/deep_path/{single_nested.name}"
657 body: "*"
658 };
659 }
660 rpc NoBindings(google.protobuf.Duration) returns (google.protobuf.Empty) {}
661 rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) {
662 option (google.api.http) = {get: "/v2/example/timeout"};
663 }
664 rpc ErrorWithDetails(google.protobuf.Empty) returns (google.protobuf.Empty) {
665 option (google.api.http) = {get: "/v2/example/errorwithdetails"};
666 }
667 rpc GetMessageWithBody(MessageWithBody) returns (google.protobuf.Empty) {
668 option (google.api.http) = {
669 post: "/v2/example/withbody/{id}",
670 body: "data"
671 };
672 }
673 rpc PostWithEmptyBody(Body) returns (google.protobuf.Empty) {
674 option (google.api.http) = {
675 post: "/v2/example/postwithemptybody/{name}",
676 body: "*"
677 };
678 }
679 rpc CheckGetQueryParams(ABitOfEverything) returns (ABitOfEverything) {
680 option (google.api.http) = {get: "/v1/example/a_bit_of_everything/params/get/{single_nested.name}"};
681 }
682 rpc CheckNestedEnumGetQueryParams(ABitOfEverything) returns (ABitOfEverything) {
683 option (google.api.http) = {get: "/v1/example/a_bit_of_everything/params/get/nested_enum/{single_nested.ok}"};
684 }
685 rpc CheckPostQueryParams(ABitOfEverything) returns (ABitOfEverything) {
686 option (google.api.http) = {
687 post: "/v1/example/a_bit_of_everything/params/post/{string_value}"
688 body: "single_nested"
689 };
690 }
691 rpc OverwriteRequestContentType(Body) returns (google.protobuf.Empty) {
692 option (google.api.http) = {
693 post: "/v2/example/overwriterequestcontenttype"
694 body: "*"
695 };
696 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {consumes: "application/x-bar-mime"};
697 }
698 rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) {
699 option (google.api.http) = {get: "/v2/example/overwriteresponsecontenttype"};
700 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {produces: "application/text"};
701 }
702 rpc CheckExternalPathEnum(pathenum.MessageWithPathEnum) returns (google.protobuf.Empty) {
703 option (google.api.http) = {get: "/v2/{value}:check"};
704 }
705 rpc CheckExternalNestedPathEnum(pathenum.MessageWithNestedPathEnum) returns (google.protobuf.Empty) {
706 option (google.api.http) = {get: "/v3/{value}:check"};
707 }
708
709 rpc CheckStatus(google.protobuf.Empty) returns (CheckStatusResponse) {
710 option (google.api.http) = {get: "/v1/example/checkStatus"};
711 }
712
713 rpc Exists(ABitOfEverything) returns (google.protobuf.Empty) {
714 option (google.api.http) = {
715 custom: {
716 kind: "HEAD",
717 path: "/v1/example/a_bit_of_everything/{uuid}"
718 }
719 };
720 }
721
722 rpc CustomOptionsRequest(ABitOfEverything) returns (google.protobuf.Empty) {
723 option (google.api.http) = {
724 custom: {
725 kind: "OPTIONS",
726 path: "/v1/example/a_bit_of_everything/{uuid}"
727 }
728 };
729 }
730
731 rpc TraceRequest(ABitOfEverything) returns (ABitOfEverything) {
732 option (google.api.http) = {
733 custom: {
734 kind: "TRACE",
735 path: "/v1/example/a_bit_of_everything/{uuid}"
736 }
737 };
738 }
739
740 rpc PostOneofEnum(grpc.gateway.examples.internal.proto.oneofenum.OneofEnumMessage) returns (google.protobuf.Empty) {
741 option (google.api.http) = {
742 post: "/v1/example/oneofenum"
743 body: "example_enum"
744 };
745 }
746
747 rpc PostRequiredMessageType(RequiredMessageTypeRequest) returns (google.protobuf.Empty) {
748 option (google.api.http) = {
749 post: "/v1/example/requiredmessagetype"
750 body: "*"
751 };
752 }
753}
754
755// camelCase and lowercase service names are valid but not recommended (use TitleCase instead)
756service camelCaseServiceName {
757 rpc Empty(google.protobuf.Empty) returns (google.protobuf.Empty) {
758 option (google.api.http) = {get: "/v2/example/empty"};
759 }
760}
761service AnotherServiceWithNoBindings {
762 rpc NoBindings(google.protobuf.Empty) returns (google.protobuf.Empty) {}
763}
764
765service SnakeEnumService {
766 rpc SnakeEnum(SnakeEnumRequest) returns (SnakeEnumResponse) {
767 option (google.api.http) = {get: "/v1/example/snake/{who}/{what}/{where}"};
768 }
769}
770
771// Ignoring lint warnings as this enum type exist to validate proper functionality
772// for projects that don't follow these lint rules.
773// buf:lint:ignore ENUM_PASCAL_CASE
774enum snake_case_enum {
775 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE
776 value_c = 0;
777 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE
778 value_d = 1;
779}
780
781// Ignoring lint warnings as this enum type exist to validate proper functionality
782// for projects that don't follow these lint rules.
783// buf:lint:ignore ENUM_PASCAL_CASE
784enum snake_case_0_enum {
785 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE
786 value_e = 0;
787 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE
788 value_f = 1;
789}
790
791message SnakeEnumRequest {
792 snake_case_enum what = 1;
793 snake_case_0_enum who = 2;
794 pathenum.snake_case_for_import where = 3;
795}
796
797message SnakeEnumResponse {}
798
799// Required message type -> OpenAPI
800// https://github.com/grpc-ecosystem/grpc-gateway/issues/2837
801message RequiredMessageTypeRequest {
802 string id = 1 [(google.api.field_behavior) = REQUIRED];
803 Foo foo = 2 [(google.api.field_behavior) = REQUIRED];
804}
805
806message Foo {
807 Bar bar = 1 [(google.api.field_behavior) = REQUIRED];
808}
809
810message Bar {
811 string id = 1 [(google.api.field_behavior) = REQUIRED];
812}
View as plain text