From af573ca50d75cc66e4a1af0d9984f203bf1e3aa0 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Sat, 16 Apr 2022 22:15:49 +0000 Subject: [PATCH] Format protobuf files with buf --- .circleci/config.yml | 1 + Makefile | 2 +- examples/internal/helloworld/helloworld.proto | 6 +- .../proto/examplepb/a_bit_of_everything.pb.go | 40 +- .../proto/examplepb/a_bit_of_everything.proto | 1308 +++++++++-------- .../proto/examplepb/echo_service.proto | 141 +- .../proto/examplepb/flow_combination.proto | 284 ++-- .../examplepb/generate_unbound_methods.proto | 31 +- .../proto/examplepb/generated_input.proto | 19 +- .../proto/examplepb/non_standard_names.proto | 96 +- .../proto/examplepb/openapi_merge_a.proto | 4 +- .../proto/examplepb/openapi_merge_b.proto | 40 +- .../examplepb/response_body_service.proto | 89 +- .../internal/proto/examplepb/stream.pb.go | 24 +- .../internal/proto/examplepb/stream.proto | 52 +- .../examplepb/unannotated_echo_service.proto | 59 +- .../proto/examplepb/use_go_template.proto | 132 +- .../examplepb/use_go_template.swagger.json | 4 +- .../visibility_rule_echo_service.proto | 135 +- .../internal/proto/examplepb/wrappers.pb.go | 6 +- .../internal/proto/examplepb/wrappers.proto | 156 +- .../internal/proto/pathenum/path_enum.proto | 20 +- examples/internal/proto/sub/message.proto | 6 +- examples/internal/proto/sub2/message.proto | 6 +- internal/descriptor/apiconfig/apiconfig.proto | 8 +- .../openapiconfig/openapiconfig.proto | 36 +- .../options/annotations.proto | 4 +- protoc-gen-openapiv2/options/openapiv2.proto | 4 +- runtime/internal/examplepb/example.pb.go | 16 +- runtime/internal/examplepb/example.proto | 22 +- .../examplepb/non_standard_names.proto | 104 +- runtime/internal/examplepb/proto3.pb.go | 12 +- runtime/internal/examplepb/proto3.proto | 6 +- 33 files changed, 1467 insertions(+), 1406 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 318b4cca4e2..5aa3d281a80 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -144,6 +144,7 @@ jobs: - checkout - run: buf build - run: buf lint + - run: buf format -w && git diff --exit-code - run: buf breaking --path protoc-gen-openapiv2/ --against 'https://github.com/grpc-ecosystem/grpc-gateway.git#branch=master' proto_push: docker: diff --git a/Makefile b/Makefile index 1914b20a82b..0570aa11cc4 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,7 @@ $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS): $(GENERATE_UNBOUND_METHODS_EXAMPLE_SPE $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/git_push.sh install: - go install github.com/bufbuild/buf/cmd/buf@v1.1.0 + go install github.com/bufbuild/buf/cmd/buf@v1.3.1 go install \ ./protoc-gen-openapiv2 \ ./protoc-gen-grpc-gateway diff --git a/examples/internal/helloworld/helloworld.proto b/examples/internal/helloworld/helloworld.proto index fae2ab00777..96ab370104c 100644 --- a/examples/internal/helloworld/helloworld.proto +++ b/examples/internal/helloworld/helloworld.proto @@ -2,13 +2,13 @@ syntax = "proto3"; package grpc.gateway.examples.internal.helloworld; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/helloworld"; - import "google/api/annotations.proto"; import "google/protobuf/wrappers.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/helloworld"; + service Greeter { - rpc SayHello (HelloRequest) returns (HelloReply) { + rpc SayHello(HelloRequest) returns (HelloReply) { option (google.api.http) = { get: "/say/{name}" additional_bindings: { diff --git a/examples/internal/proto/examplepb/a_bit_of_everything.pb.go b/examples/internal/proto/examplepb/a_bit_of_everything.pb.go index 8eccb73f90e..22b3a2f2701 100644 --- a/examples/internal/proto/examplepb/a_bit_of_everything.pb.go +++ b/examples/internal/proto/examplepb/a_bit_of_everything.pb.go @@ -1298,29 +1298,29 @@ var file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDesc = [ 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, - 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, - 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, - 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, - 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x70, 0x61, - 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x29, 0x65, + 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2f, + 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, diff --git a/examples/internal/proto/examplepb/a_bit_of_everything.proto b/examples/internal/proto/examplepb/a_bit_of_everything.proto index 5fc0960000e..b74a23ba25e 100644 --- a/examples/internal/proto/examplepb/a_bit_of_everything.proto +++ b/examples/internal/proto/examplepb/a_bit_of_everything.proto @@ -1,397 +1,432 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; -import "google/api/annotations.proto"; -import "google/api/field_behavior.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/wrappers.proto"; import "examples/internal/proto/pathenum/path_enum.proto"; import "examples/internal/proto/sub/message.proto"; import "examples/internal/proto/sub2/message.proto"; +import "google/api/annotations.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; import "google/rpc/status.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { - info: { - title: "A Bit of Everything"; - version: "1.0"; - contact: { - name: "gRPC-Gateway project"; - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - email: "none@example.com"; - }; - license: { - name: "BSD 3-Clause License"; - url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; - }; - extensions: { - key: "x-something-something"; - value { - string_value: "yadda"; - } - } - }; - // Overwriting host entry breaks tests, so this is not done here. - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "More about gRPC-Gateway"; - } - schemes: HTTP; - schemes: HTTPS; - schemes: WSS; - consumes: "application/json"; - consumes: "application/x-foo-mime"; - produces: "application/json"; - produces: "application/x-foo-mime"; - security_definitions: { - security: { - key: "BasicAuth"; - value: { - type: TYPE_BASIC; - } - } - security: { - key: "ApiKeyAuth"; - value: { - type: TYPE_API_KEY; - in: IN_HEADER; - name: "X-API-Key"; - extensions: { - key: "x-amazon-apigateway-authtype"; - value { - string_value: "oauth2"; - } - } - extensions: { - key: "x-amazon-apigateway-authorizer"; - value { - struct_value { - fields { - key: "type"; - value { - string_value: "token"; - } - } - fields { - key: "authorizerResultTtlInSeconds"; - value { - number_value: 60; - } - } - } - } - } - } - } - security: { - key: "OAuth2"; - value: { - type: TYPE_OAUTH2; - flow: FLOW_ACCESS_CODE; - authorization_url: "https://example.com/oauth/authorize"; - token_url: "https://example.com/oauth/token"; - scopes: { - scope: { - key: "read"; - value: "Grants read access"; - } - scope: { - key: "write"; - value: "Grants write access"; - } - scope: { - key: "admin"; - value: "Grants read and write access to administrative information"; - } - } - } - } - } - security: { - security_requirement: { - key: "BasicAuth"; - value: {}; - } - security_requirement: { - key: "ApiKeyAuth"; - value: {}; - } - } - security: { - security_requirement: { - key: "OAuth2"; - value: { - scope: "read"; - scope: "write"; - } - } - security_requirement: { - key: "ApiKeyAuth"; - value: {}; - } - } - responses: { - key: "403"; - value: { - description: "Returned when the user does not have permission to access the resource."; - } - } - responses: { - key: "404"; - value: { - description: "Returned when the resource does not exist."; - schema: { - json_schema: { - type: STRING; - } - } - } - } - responses: { - key: "418"; - value: { - description: "I'm a teapot."; - schema: { - json_schema: { - ref: ".grpc.gateway.examples.internal.proto.examplepb.NumericEnum"; - } - } - } - } - responses: { - key: "500"; - value: { - description: "Server error"; - headers: { - key: "X-Correlation-Id" - value: { - description: "Unique event identifier for server requests" - type: "string" - format: "uuid" - default: "\"2438ac3c-37eb-4902-adef-ed16b4431030\"" - pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$" - } - }; - schema: { - json_schema: { - ref: ".grpc.gateway.examples.internal.proto.examplepb.ErrorResponse"; - } - } - } - } - extensions: { - key: "x-grpc-gateway-foo"; - value { - string_value: "bar"; - } - } - extensions: { - key: "x-grpc-gateway-baz-list"; - value { - list_value: { - values: { - string_value: "one"; - } - values: { - bool_value: true; - } - } - } - } + info: { + title: "A Bit of Everything"; + version: "1.0"; + contact: { + name: "gRPC-Gateway project"; + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + email: "none@example.com"; + }; + license: { + name: "BSD 3-Clause License"; + url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; + }; + extensions: { + key: "x-something-something"; + value { + string_value: "yadda"; + } + } + }; + // Overwriting host entry breaks tests, so this is not done here. + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "More about gRPC-Gateway"; + } + schemes: HTTP; + schemes: HTTPS; + schemes: WSS; + consumes: "application/json"; + consumes: "application/x-foo-mime"; + produces: "application/json"; + produces: "application/x-foo-mime"; + security_definitions: { + security: { + key: "BasicAuth"; + value: { + type: TYPE_BASIC; + } + } + security: { + key: "ApiKeyAuth"; + value: { + type: TYPE_API_KEY; + in: IN_HEADER; + name: "X-API-Key"; + extensions: { + key: "x-amazon-apigateway-authtype"; + value { + string_value: "oauth2"; + } + } + extensions: { + key: "x-amazon-apigateway-authorizer"; + value { + struct_value { + fields { + key: "type"; + value { + string_value: "token"; + } + } + fields { + key: "authorizerResultTtlInSeconds"; + value { + number_value: 60; + } + } + } + } + } + } + } + security: { + key: "OAuth2"; + value: { + type: TYPE_OAUTH2; + flow: FLOW_ACCESS_CODE; + authorization_url: "https://example.com/oauth/authorize"; + token_url: "https://example.com/oauth/token"; + scopes: { + scope: { + key: "read"; + value: "Grants read access"; + } + scope: { + key: "write"; + value: "Grants write access"; + } + scope: { + key: "admin"; + value: "Grants read and write access to administrative information"; + } + } + } + } + } + security: { + security_requirement: { + key: "BasicAuth"; + value: {}; + } + security_requirement: { + key: "ApiKeyAuth"; + value: {}; + } + } + security: { + security_requirement: { + key: "OAuth2"; + value: { + scope: "read"; + scope: "write"; + } + } + security_requirement: { + key: "ApiKeyAuth"; + value: {}; + } + } + responses: { + key: "403"; + value: { + description: "Returned when the user does not have permission to access the resource."; + } + } + responses: { + key: "404"; + value: { + description: "Returned when the resource does not exist."; + schema: { + json_schema: { + type: STRING; + } + } + } + } + responses: { + key: "418"; + value: { + description: "I'm a teapot."; + schema: { + json_schema: { + ref: ".grpc.gateway.examples.internal.proto.examplepb.NumericEnum"; + } + } + } + } + responses: { + key: "500"; + value: { + description: "Server error"; + headers: { + key: "X-Correlation-Id" + value: { + description: "Unique event identifier for server requests" + type: "string" + format: "uuid" + default: "\"2438ac3c-37eb-4902-adef-ed16b4431030\"" + pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$" + } + }; + schema: { + json_schema: { + ref: ".grpc.gateway.examples.internal.proto.examplepb.ErrorResponse"; + } + } + } + } + extensions: { + key: "x-grpc-gateway-foo"; + value { + string_value: "bar"; + } + } + extensions: { + key: "x-grpc-gateway-baz-list"; + value { + list_value: { + values: { + string_value: "one"; + } + values: { + bool_value: true; + } + } + } + } }; -message ErrorResponse{ - string correlationId = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$", - title: "x-correlation-id", - description: "Unique event identifier for server requests", - format: "uuid", - example: "\"2438ac3c-37eb-4902-adef-ed16b4431030\"" - }]; - ErrorObject error = 2; +message ErrorResponse { + string correlationId = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$", + title: "x-correlation-id", + description: "Unique event identifier for server requests", + format: "uuid", + example: "\"2438ac3c-37eb-4902-adef-ed16b4431030\"" + }]; + ErrorObject error = 2; } -message ErrorObject{ - int32 code = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - pattern: "^[0-9]$", - title: "code", - description: "Response code", - format: "integer" - }]; - string message = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - pattern: "^[a-zA-Z0-9]{1, 32}$", - title: "message", - description: "Response message" - }]; +message ErrorObject { + int32 code = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + pattern: "^[0-9]$", + title: "code", + description: "Response code", + format: "integer" + }]; + string message = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + pattern: "^[a-zA-Z0-9]{1, 32}$", + title: "message", + description: "Response message" + }]; } - // Intentionally complicated message type to cover many features of Protobuf. message ABitOfEverything { - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { - json_schema: { - title: "A bit of everything" - description: "Intentionally complicated message type to cover many features of Protobuf." - required: ["uuid", "int64_value", "double_value"] - extensions: { - key: "x-a-bit-of-everything-foo"; - value { - string_value: "bar"; - } - } - } - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more about ABitOfEverything"; - } - example: "{\"int64_value\": 12, \"double_value\": 12.3}" - }; - - // Nested is nested type. - message Nested { - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { - example: "{\"ok\": \"TRUE\"}" - }; - // name is nested field. - string name = 1; - uint32 amount = 2; - // DeepEnum is one or zero. - enum DeepEnum { - // FALSE is false. - FALSE = 0; - // TRUE is true. - TRUE = 1; - } - - // DeepEnum comment. - DeepEnum ok = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "DeepEnum description."}]; - } - Nested single_nested = 25; - - string uuid = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - 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}", - min_length: 1, - field_configuration: {path_param_name: "uuidName"}, - extensions: {key: "x-internal"; value {bool_value: true}} - }]; - repeated Nested nested = 2; - float float_value = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Float value field", default: "0.2", required: ['float_value']}]; - double double_value = 4; - int64 int64_value = 5; - uint64 uint64_value = 6; - int32 int32_value = 7; - fixed64 fixed64_value = 8; - fixed32 fixed32_value = 9; - bool bool_value = 10; - string string_value = 11; - bytes bytes_value = 29; - uint32 uint32_value = 13; - NumericEnum enum_value = 14; - pathenum.PathEnum path_enum_value = 30; - pathenum.MessagePathEnum.NestedPathEnum nested_path_enum_value = 31; - sfixed32 sfixed32_value = 15; - sfixed64 sfixed64_value = 16; - sint32 sint32_value = 17; - sint64 sint64_value = 18; - repeated string repeated_string_value = 19; - oneof oneof_value { - google.protobuf.Empty oneof_empty = 20; - string oneof_string = 21; - } - - map map_value = 22; - map mapped_string_value = 23; - map mapped_nested_value = 24; - - string nonConventionalNameValue = 26; - - google.protobuf.Timestamp timestamp_value = 27; - - // repeated enum value. it is comma-separated in query - repeated NumericEnum repeated_enum_value = 28; - - // repeated numeric enum comment (This comment is overridden by the field annotation) - repeated NumericEnum repeated_enum_annotation = 32 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {title: "Repeated numeric enum title", description: "Repeated numeric enum description."}]; - - // numeric enum comment (This comment is overridden by the field annotation) - NumericEnum enum_value_annotation = 33 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {title: "Numeric enum title", description: "Numeric enum description."}]; - - // repeated string comment (This comment is overridden by the field annotation) - repeated string repeated_string_annotation = 34 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {title: "Repeated string title", description: "Repeated string description."}]; - - // repeated nested object comment (This comment is overridden by the field annotation) - repeated Nested repeated_nested_annotation = 35 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {title: "Repeated nested object title", description: "Repeated nested object description."}]; - - // nested object comments (This comment is overridden by the field annotation) - Nested nested_annotation = 36 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {title: "Nested object title", description: "Nested object description."}]; - - int64 int64_override_type = 37 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {type: INTEGER}]; - - // mark a field as required in Open API definition - string required_string_via_field_behavior_annotation = 38 [(google.api.field_behavior) = REQUIRED]; - - // mark a field as readonly in Open API definition - string output_only_string_via_field_behavior_annotation = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; - - optional string optional_string_value = 40; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "A bit of everything" + description: "Intentionally complicated message type to cover many features of Protobuf." + required: [ + "uuid", + "int64_value", + "double_value" + ] + extensions: { + key: "x-a-bit-of-everything-foo"; + value { + string_value: "bar"; + } + } + } + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about ABitOfEverything"; + } + example: "{\"int64_value\": 12, \"double_value\": 12.3}" + }; + + // Nested is nested type. + message Nested { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example: "{\"ok\": \"TRUE\"}" + }; + // name is nested field. + string name = 1; + uint32 amount = 2; + // DeepEnum is one or zero. + enum DeepEnum { + // FALSE is false. + FALSE = 0; + // TRUE is true. + TRUE = 1; + } + + // DeepEnum comment. + DeepEnum ok = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + description: "DeepEnum description." + }]; + } + Nested single_nested = 25; + + string uuid = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + 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}", + min_length: 1, + field_configuration: { + path_param_name: "uuidName" + }, + extensions: { + key: "x-internal"; + value { + bool_value: true + } + } + }]; + repeated Nested nested = 2; + float float_value = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + description: "Float value field", + default: "0.2", + required: [ + "float_value" + ] + }]; + double double_value = 4; + int64 int64_value = 5; + uint64 uint64_value = 6; + int32 int32_value = 7; + fixed64 fixed64_value = 8; + fixed32 fixed32_value = 9; + bool bool_value = 10; + string string_value = 11; + bytes bytes_value = 29; + uint32 uint32_value = 13; + NumericEnum enum_value = 14; + pathenum.PathEnum path_enum_value = 30; + pathenum.MessagePathEnum.NestedPathEnum nested_path_enum_value = 31; + sfixed32 sfixed32_value = 15; + sfixed64 sfixed64_value = 16; + sint32 sint32_value = 17; + sint64 sint64_value = 18; + repeated string repeated_string_value = 19; + oneof oneof_value { + google.protobuf.Empty oneof_empty = 20; + string oneof_string = 21; + } + + map map_value = 22; + map mapped_string_value = 23; + map mapped_nested_value = 24; + + string nonConventionalNameValue = 26; + + google.protobuf.Timestamp timestamp_value = 27; + + // repeated enum value. it is comma-separated in query + repeated NumericEnum repeated_enum_value = 28; + + // repeated numeric enum comment (This comment is overridden by the field annotation) + repeated NumericEnum repeated_enum_annotation = 32 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Repeated numeric enum title", + description: "Repeated numeric enum description." + }]; + + // numeric enum comment (This comment is overridden by the field annotation) + NumericEnum enum_value_annotation = 33 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Numeric enum title", + description: "Numeric enum description." + }]; + + // repeated string comment (This comment is overridden by the field annotation) + repeated string repeated_string_annotation = 34 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Repeated string title", + description: "Repeated string description." + }]; + + // repeated nested object comment (This comment is overridden by the field annotation) + repeated Nested repeated_nested_annotation = 35 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Repeated nested object title", + description: "Repeated nested object description." + }]; + + // nested object comments (This comment is overridden by the field annotation) + Nested nested_annotation = 36 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Nested object title", + description: "Nested object description." + }]; + + int64 int64_override_type = 37 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + type: INTEGER + }]; + + // mark a field as required in Open API definition + string required_string_via_field_behavior_annotation = 38 [(google.api.field_behavior) = REQUIRED]; + + // mark a field as readonly in Open API definition + string output_only_string_via_field_behavior_annotation = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; + + optional string optional_string_value = 40; } // ABitOfEverythingRepeated is used to validate repeated path parameter functionality message ABitOfEverythingRepeated { - 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]}" - }; - - // repeated values. they are comma-separated in path - repeated float path_repeated_float_value = 1; - repeated double path_repeated_double_value = 2; - repeated int64 path_repeated_int64_value = 3; - repeated uint64 path_repeated_uint64_value = 4; - repeated int32 path_repeated_int32_value = 5; - repeated fixed64 path_repeated_fixed64_value = 6; - repeated fixed32 path_repeated_fixed32_value = 7; - repeated bool path_repeated_bool_value = 8; - repeated string path_repeated_string_value = 9; - repeated bytes path_repeated_bytes_value = 10; - repeated uint32 path_repeated_uint32_value = 11; - repeated NumericEnum path_repeated_enum_value = 12; - repeated sfixed32 path_repeated_sfixed32_value = 13; - repeated sfixed64 path_repeated_sfixed64_value = 14; - repeated sint32 path_repeated_sint32_value = 15; - repeated sint64 path_repeated_sint64_value = 16; + 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]}" + }; + + // repeated values. they are comma-separated in path + repeated float path_repeated_float_value = 1; + repeated double path_repeated_double_value = 2; + repeated int64 path_repeated_int64_value = 3; + repeated uint64 path_repeated_uint64_value = 4; + repeated int32 path_repeated_int32_value = 5; + repeated fixed64 path_repeated_fixed64_value = 6; + repeated fixed32 path_repeated_fixed32_value = 7; + repeated bool path_repeated_bool_value = 8; + repeated string path_repeated_string_value = 9; + repeated bytes path_repeated_bytes_value = 10; + repeated uint32 path_repeated_uint32_value = 11; + repeated NumericEnum path_repeated_enum_value = 12; + repeated sfixed32 path_repeated_sfixed32_value = 13; + repeated sfixed64 path_repeated_sfixed64_value = 14; + repeated sint32 path_repeated_sint32_value = 15; + repeated sint64 path_repeated_sint64_value = 16; } message CheckStatusResponse { - google.rpc.Status status = 1; + google.rpc.Status status = 1; } message Body { - string name = 1; + string name = 1; } message MessageWithBody { - string id = 1; - Body data = 2; + string id = 1; + Body data = 2; } - // NumericEnum is one or zero. enum NumericEnum { - // ZERO means 0 - ZERO = 0; - // ONE means 1 - ONE = 1; + // ZERO means 0 + ZERO = 0; + // ONE means 1 + ONE = 1; } // UpdateV2Request request for update includes the message and the update mask message UpdateV2Request { - ABitOfEverything abe = 1; - // The paths to update. - google.protobuf.FieldMask update_mask = 2; + ABitOfEverything abe = 1; + // The paths to update. + google.protobuf.FieldMask update_mask = 2; } // An example resource type from AIP-123 used to test the behavior described in @@ -399,18 +434,18 @@ message UpdateV2Request { // // See: https://google.aip.dev/123 message Book { - // The resource name of the book. - // - // Format: `publishers/{publisher}/books/{book}` - // - // Example: `publishers/1257894000000000000/books/my-book` - string name = 1; - - // Output only. The book's ID. - string id = 2; - - // Output only. Creation time of the book. - google.protobuf.Timestamp create_time = 3; + // The resource name of the book. + // + // Format: `publishers/{publisher}/books/{book}` + // + // Example: `publishers/1257894000000000000/books/my-book` + string name = 1; + + // Output only. The book's ID. + string id = 2; + + // Output only. Creation time of the book. + google.protobuf.Timestamp create_time = 3; } // A standard Create message from AIP-133 with a user-specified ID. @@ -419,293 +454,290 @@ message Book { // // See: https://google.aip.dev/133#user-specified-ids message CreateBookRequest { - // The publisher in which to create the book. - // - // Format: `publishers/{publisher}` - // - // Example: `publishers/1257894000000000000` - string parent = 1; - - // The book to create. - Book book = 2; - - // The ID to use for the book. - // - // This must start with an alphanumeric character. - string book_id = 3; + // The publisher in which to create the book. + // + // Format: `publishers/{publisher}` + // + // Example: `publishers/1257894000000000000` + string parent = 1; + + // The book to create. + Book book = 2; + + // The ID to use for the book. + // + // This must start with an alphanumeric character. + string book_id = 3; } // A standard Update message from AIP-134 // // See: https://google.aip.dev/134#request-message message UpdateBookRequest { - // The book to update. - // - // The book's `name` field is used to identify the book to be updated. - // Format: publishers/{publisher}/books/{book} - Book book = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the book is not found, a new book will be created. - // In this situation, `update_mask` is ignored. - bool allow_missing = 3; - + // The book to update. + // + // The book's `name` field is used to identify the book to be updated. + // Format: publishers/{publisher}/books/{book} + Book book = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the book is not found, a new book will be created. + // In this situation, `update_mask` is ignored. + bool allow_missing = 3; } // ABitOfEverything service is used to validate that APIs with complicated // proto messages and URL templates are still processed correctly. service ABitOfEverythingService { - - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { - description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!" - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more about EchoService"; - } - }; - - // Create a new ABitOfEverything - // - // This API creates a new ABitOfEverything - rpc Create(ABitOfEverything) returns (ABitOfEverything) { - 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}" - }; - } - rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) { - option (google.api.http) = { - post: "/v1/example/a_bit_of_everything" - body: "*" - }; - } - // Create a book. - rpc CreateBook(CreateBookRequest) returns (Book) { - option (google.api.http) = { - post: "/v1/{parent=publishers/*}/books" - body: "book" - }; - } - rpc UpdateBook(UpdateBookRequest) returns (Book) { - option (google.api.http) = { - patch: "/v1/{book.name=publishers/*/books/*}" - body: "book" - }; - } - rpc Lookup(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (ABitOfEverything) { - option (google.api.http) = { - get: "/v1/example/a_bit_of_everything/{uuid}" - }; - } - rpc Update(ABitOfEverything) returns (google.protobuf.Empty) { - option (google.api.http) = { - put: "/v1/example/a_bit_of_everything/{uuid}" - body: "*" - }; - } - rpc UpdateV2(UpdateV2Request) returns (google.protobuf.Empty) { - option (google.api.http) = { - put: "/v2/example/a_bit_of_everything/{abe.uuid}" - body: "abe" - additional_bindings: [ - { - patch: "/v2/example/a_bit_of_everything/{abe.uuid}" - body: "abe" - }, - { - patch: "/v2a/example/a_bit_of_everything/{abe.uuid}" - body: "*" - } - ] - }; - } - - rpc Delete(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/example/a_bit_of_everything/{uuid}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - security: { - security_requirement: { - key: "ApiKeyAuth"; - value: {} - } - security_requirement: { - key: "OAuth2"; - value: { - scope: "read"; - scope: "write"; - } - } - } - extensions: { - key: "x-irreversible"; - value { - bool_value: true; - } - } - }; - } - rpc GetQuery(ABitOfEverything) returns (google.protobuf.Empty) { - option (google.api.http) = { - get: "/v1/example/a_bit_of_everything/query/{uuid}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - deprecated: true // For testing purposes. - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more about GetQuery"; - } - security: { - } - }; - } - rpc GetRepeatedQuery(ABitOfEverythingRepeated) returns (ABitOfEverythingRepeated) { - 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}" - }; - } - // Echo allows posting a StringMessage value. - // - // It also exposes multiple bindings. - // - // This makes it useful when validating that the OpenAPI v2 API - // description exposes documentation correctly on all paths - // defined as additional_bindings in the proto. - rpc Echo(grpc.gateway.examples.internal.proto.sub.StringMessage) returns (grpc.gateway.examples.internal.proto.sub.StringMessage) { - option (google.api.http) = { - get: "/v1/example/a_bit_of_everything/echo/{value}" - additional_bindings { - post: "/v2/example/echo" - body: "value" - } - additional_bindings { - get: "/v2/example/echo" - } - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - description: "Description Echo"; - summary: "Summary: Echo rpc"; - tags: "echo rpc"; - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more Echo"; - } - responses: { - key: "200" - value: { - examples: { - key: "application/json" - value: '{"value": "the input value"}' - } - } - } - responses: { - key: "503"; - value: { - description: "Returned when the resource is temporarily unavailable."; - extensions: { - key: "x-number"; - value { - number_value: 100; - } - } - } - } - responses: { - // Overwrites global definition. - key: "404"; - value: { - description: "Returned when the resource does not exist."; - schema: { - json_schema: { - type: INTEGER; - } - } - } - } - }; - } - rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { - option (google.api.http) = { - post: "/v1/example/deep_path/{single_nested.name}" - body: "*" - }; - } - rpc NoBindings(google.protobuf.Duration) returns (google.protobuf.Empty) {} - rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) { - option (google.api.http) = { - get: "/v2/example/timeout", - }; - } - rpc ErrorWithDetails(google.protobuf.Empty) returns (google.protobuf.Empty) { - option (google.api.http) = { - get: "/v2/example/errorwithdetails", - }; - } - rpc GetMessageWithBody(MessageWithBody) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2/example/withbody/{id}", - body: "data" - }; - } - rpc PostWithEmptyBody(Body) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2/example/postwithemptybody/{name}", - body: "*" - }; - } - rpc CheckGetQueryParams(ABitOfEverything) returns (ABitOfEverything) { - option (google.api.http) = { - get: "/v1/example/a_bit_of_everything/params/get/{single_nested.name}" - }; - } - rpc CheckNestedEnumGetQueryParams(ABitOfEverything) returns (ABitOfEverything) { - option (google.api.http) = { - get: "/v1/example/a_bit_of_everything/params/get/nested_enum/{single_nested.ok}" - }; - } - rpc CheckPostQueryParams(ABitOfEverything) returns (ABitOfEverything) { - option (google.api.http) = { - post: "/v1/example/a_bit_of_everything/params/post/{string_value}" - body: "single_nested" - }; - } - rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) { - option (google.api.http) = { - get: "/v2/example/overwriteresponsecontenttype" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - produces: "application/text" - }; - } - rpc CheckExternalPathEnum(pathenum.MessageWithPathEnum) returns (google.protobuf.Empty) { - option (google.api.http) = { - get: "/v2/{value}:check" - }; - } - rpc CheckExternalNestedPathEnum(pathenum.MessageWithNestedPathEnum) returns (google.protobuf.Empty) { - option (google.api.http) = { - get: "/v3/{value}:check" - }; - } - - rpc CheckStatus(google.protobuf.Empty) returns (CheckStatusResponse) { - option (google.api.http) = { - get: "/v1/example/checkStatus" - }; - } + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { + description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!" + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about EchoService"; + } + }; + + // Create a new ABitOfEverything + // + // This API creates a new ABitOfEverything + rpc Create(ABitOfEverything) returns (ABitOfEverything) { + 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}" + }; + } + rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) { + option (google.api.http) = { + post: "/v1/example/a_bit_of_everything" + body: "*" + }; + } + // Create a book. + rpc CreateBook(CreateBookRequest) returns (Book) { + option (google.api.http) = { + post: "/v1/{parent=publishers/*}/books" + body: "book" + }; + } + rpc UpdateBook(UpdateBookRequest) returns (Book) { + option (google.api.http) = { + patch: "/v1/{book.name=publishers/*/books/*}" + body: "book" + }; + } + rpc Lookup(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (ABitOfEverything) { + option (google.api.http) = { + get: "/v1/example/a_bit_of_everything/{uuid}" + }; + } + rpc Update(ABitOfEverything) returns (google.protobuf.Empty) { + option (google.api.http) = { + put: "/v1/example/a_bit_of_everything/{uuid}" + body: "*" + }; + } + rpc UpdateV2(UpdateV2Request) returns (google.protobuf.Empty) { + option (google.api.http) = { + put: "/v2/example/a_bit_of_everything/{abe.uuid}" + body: "abe" + additional_bindings: [ + { + patch: "/v2/example/a_bit_of_everything/{abe.uuid}" + body: "abe" + }, + { + patch: "/v2a/example/a_bit_of_everything/{abe.uuid}" + body: "*" + } + ] + }; + } + + rpc Delete(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/example/a_bit_of_everything/{uuid}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + security: { + security_requirement: { + key: "ApiKeyAuth"; + value: {} + } + security_requirement: { + key: "OAuth2"; + value: { + scope: "read"; + scope: "write"; + } + } + } + extensions: { + key: "x-irreversible"; + value { + bool_value: true; + } + } + }; + } + rpc GetQuery(ABitOfEverything) returns (google.protobuf.Empty) { + option (google.api.http) = { + get: "/v1/example/a_bit_of_everything/query/{uuid}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + deprecated: true // For testing purposes. + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about GetQuery"; + } + security: {} + }; + } + rpc GetRepeatedQuery(ABitOfEverythingRepeated) returns (ABitOfEverythingRepeated) { + 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}" + }; + } + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. + rpc Echo(grpc.gateway.examples.internal.proto.sub.StringMessage) returns (grpc.gateway.examples.internal.proto.sub.StringMessage) { + option (google.api.http) = { + get: "/v1/example/a_bit_of_everything/echo/{value}" + additional_bindings { + post: "/v2/example/echo" + body: "value" + } + additional_bindings { + get: "/v2/example/echo" + } + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + description: "Description Echo"; + summary: "Summary: Echo rpc"; + tags: "echo rpc"; + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more Echo"; + } + responses: { + key: "200" + value: { + examples: { + key: "application/json" + value: "{\"value\": \"the input value\"}" + } + } + } + responses: { + key: "503"; + value: { + description: "Returned when the resource is temporarily unavailable."; + extensions: { + key: "x-number"; + value { + number_value: 100; + } + } + } + } + responses: { + // Overwrites global definition. + key: "404"; + value: { + description: "Returned when the resource does not exist."; + schema: { + json_schema: { + type: INTEGER; + } + } + } + } + }; + } + rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { + option (google.api.http) = { + post: "/v1/example/deep_path/{single_nested.name}" + body: "*" + }; + } + rpc NoBindings(google.protobuf.Duration) returns (google.protobuf.Empty) {} + rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) { + option (google.api.http) = { + get: "/v2/example/timeout", + }; + } + rpc ErrorWithDetails(google.protobuf.Empty) returns (google.protobuf.Empty) { + option (google.api.http) = { + get: "/v2/example/errorwithdetails", + }; + } + rpc GetMessageWithBody(MessageWithBody) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2/example/withbody/{id}", + body: "data" + }; + } + rpc PostWithEmptyBody(Body) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2/example/postwithemptybody/{name}", + body: "*" + }; + } + rpc CheckGetQueryParams(ABitOfEverything) returns (ABitOfEverything) { + option (google.api.http) = { + get: "/v1/example/a_bit_of_everything/params/get/{single_nested.name}" + }; + } + rpc CheckNestedEnumGetQueryParams(ABitOfEverything) returns (ABitOfEverything) { + option (google.api.http) = { + get: "/v1/example/a_bit_of_everything/params/get/nested_enum/{single_nested.ok}" + }; + } + rpc CheckPostQueryParams(ABitOfEverything) returns (ABitOfEverything) { + option (google.api.http) = { + post: "/v1/example/a_bit_of_everything/params/post/{string_value}" + body: "single_nested" + }; + } + rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) { + option (google.api.http) = { + get: "/v2/example/overwriteresponsecontenttype" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + produces: "application/text" + }; + } + rpc CheckExternalPathEnum(pathenum.MessageWithPathEnum) returns (google.protobuf.Empty) { + option (google.api.http) = { + get: "/v2/{value}:check" + }; + } + rpc CheckExternalNestedPathEnum(pathenum.MessageWithNestedPathEnum) returns (google.protobuf.Empty) { + option (google.api.http) = { + get: "/v3/{value}:check" + }; + } + + rpc CheckStatus(google.protobuf.Empty) returns (CheckStatusResponse) { + option (google.api.http) = { + get: "/v1/example/checkStatus" + }; + } } // camelCase and lowercase service names are valid but not recommended (use TitleCase instead) service camelCaseServiceName { - rpc Empty(google.protobuf.Empty) returns (google.protobuf.Empty) { - option (google.api.http) = { - get: "/v2/example/empty", - }; - } + rpc Empty(google.protobuf.Empty) returns (google.protobuf.Empty) { + option (google.api.http) = { + get: "/v2/example/empty", + }; + } } service AnotherServiceWithNoBindings { - rpc NoBindings(google.protobuf.Empty) returns (google.protobuf.Empty) {} + rpc NoBindings(google.protobuf.Empty) returns (google.protobuf.Empty) {} } diff --git a/examples/internal/proto/examplepb/echo_service.proto b/examples/internal/proto/examplepb/echo_service.proto index 88ae6d8bbc3..679f8f241c9 100644 --- a/examples/internal/proto/examplepb/echo_service.proto +++ b/examples/internal/proto/examplepb/echo_service.proto @@ -1,5 +1,4 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Echo Service // @@ -11,91 +10,93 @@ import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/struct.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + // Embedded represents a message embedded in SimpleMessage. message Embedded { - oneof mark { - int64 progress = 1; - string note = 2; - } + oneof mark { + int64 progress = 1; + string note = 2; + } } // SimpleMessage represents a simple message sent to the Echo service. message SimpleMessage { - // Id represents the message identifier. - string id = 1; - int64 num = 2; - oneof code { - int64 line_num = 3; - string lang = 4; - } - Embedded status = 5; - oneof ext { - int64 en = 6; - Embedded no = 7; - } + // Id represents the message identifier. + string id = 1; + int64 num = 2; + oneof code { + int64 line_num = 3; + string lang = 4; + } + Embedded status = 5; + oneof ext { + int64 en = 6; + Embedded no = 7; + } } // DynamicMessage represents a message which can have its structure // built dynamically using Struct and Values. message DynamicMessage { - google.protobuf.Struct struct_field = 1; - google.protobuf.Value value_field = 2; + google.protobuf.Struct struct_field = 1; + google.protobuf.Value value_field = 2; } message DynamicMessageUpdate { - DynamicMessage body = 1; - google.protobuf.FieldMask update_mask = 2; + DynamicMessage body = 1; + google.protobuf.FieldMask update_mask = 2; } // Echo service responds to incoming echo requests. service EchoService { - // Echo method receives a simple message and returns it. - // - // The message posted as the id parameter will also be - // returned. - rpc Echo(SimpleMessage) returns (SimpleMessage) { - option (google.api.http) = { - post: "/v1/example/echo/{id}" - additional_bindings { - get: "/v1/example/echo/{id}/{num}" - } - additional_bindings { - get: "/v1/example/echo/{id}/{num}/{lang}" - } - additional_bindings { - get: "/v1/example/echo1/{id}/{line_num}/{status.note}" - } - additional_bindings { - get: "/v1/example/echo2/{no.note}" - } - }; - } - // EchoBody method receives a simple message and returns it. - rpc EchoBody(SimpleMessage) returns (SimpleMessage) { - option (google.api.http) = { - post: "/v1/example/echo_body" - body: "*" - }; - } - // EchoDelete method receives a simple message and returns it. - rpc EchoDelete(SimpleMessage) returns (SimpleMessage) { - option (google.api.http) = { - delete: "/v1/example/echo_delete" - }; - } - // EchoPatch method receives a NonStandardUpdateRequest and returns it. - rpc EchoPatch(DynamicMessageUpdate) returns (DynamicMessageUpdate) { - option (google.api.http) = { - patch: "/v1/example/echo_patch" - body: "body" - }; - } - // EchoUnauthorized method receives a simple message and returns it. It must - // always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code - // of 401. - rpc EchoUnauthorized(SimpleMessage) returns (SimpleMessage) { - option (google.api.http) = { - get: "/v1/example/echo_unauthorized" - }; - } + // Echo method receives a simple message and returns it. + // + // The message posted as the id parameter will also be + // returned. + rpc Echo(SimpleMessage) returns (SimpleMessage) { + option (google.api.http) = { + post: "/v1/example/echo/{id}" + additional_bindings { + get: "/v1/example/echo/{id}/{num}" + } + additional_bindings { + get: "/v1/example/echo/{id}/{num}/{lang}" + } + additional_bindings { + get: "/v1/example/echo1/{id}/{line_num}/{status.note}" + } + additional_bindings { + get: "/v1/example/echo2/{no.note}" + } + }; + } + // EchoBody method receives a simple message and returns it. + rpc EchoBody(SimpleMessage) returns (SimpleMessage) { + option (google.api.http) = { + post: "/v1/example/echo_body" + body: "*" + }; + } + // EchoDelete method receives a simple message and returns it. + rpc EchoDelete(SimpleMessage) returns (SimpleMessage) { + option (google.api.http) = { + delete: "/v1/example/echo_delete" + }; + } + // EchoPatch method receives a NonStandardUpdateRequest and returns it. + rpc EchoPatch(DynamicMessageUpdate) returns (DynamicMessageUpdate) { + option (google.api.http) = { + patch: "/v1/example/echo_patch" + body: "body" + }; + } + // EchoUnauthorized method receives a simple message and returns it. It must + // always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code + // of 401. + rpc EchoUnauthorized(SimpleMessage) returns (SimpleMessage) { + option (google.api.http) = { + get: "/v1/example/echo_unauthorized" + }; + } } diff --git a/examples/internal/proto/examplepb/flow_combination.proto b/examples/internal/proto/examplepb/flow_combination.proto index bb5fc0a2287..59a351d331f 100644 --- a/examples/internal/proto/examplepb/flow_combination.proto +++ b/examples/internal/proto/examplepb/flow_combination.proto @@ -1,168 +1,170 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + message EmptyProto {} message NonEmptyProto { - string a = 1; - string b = 2; - string c = 3; + string a = 1; + string b = 2; + string c = 3; } message UnaryProto { - string str = 1; + string str = 1; } message NestedProto { - UnaryProto a = 1; - string b = 2; - string c = 3; + UnaryProto a = 1; + string b = 2; + string c = 3; } message SingleNestedProto { - UnaryProto a = 1; + UnaryProto a = 1; } service FlowCombination { - rpc RpcEmptyRpc(EmptyProto) returns (EmptyProto) { - option (google.api.http) = { - post: "/rpc/empty/rpc" - }; - } - rpc RpcEmptyStream(EmptyProto) returns (stream EmptyProto) { - option (google.api.http) = { - post: "/rpc/empty/stream" - }; - } - rpc StreamEmptyRpc(stream EmptyProto) returns (EmptyProto) { - option (google.api.http) = { - post: "/stream/empty/rpc" - }; - } - rpc StreamEmptyStream(stream EmptyProto) returns (stream EmptyProto) { - option (google.api.http) = { - post: "/stream/empty/stream" - }; - } + rpc RpcEmptyRpc(EmptyProto) returns (EmptyProto) { + option (google.api.http) = { + post: "/rpc/empty/rpc" + }; + } + rpc RpcEmptyStream(EmptyProto) returns (stream EmptyProto) { + option (google.api.http) = { + post: "/rpc/empty/stream" + }; + } + rpc StreamEmptyRpc(stream EmptyProto) returns (EmptyProto) { + option (google.api.http) = { + post: "/stream/empty/rpc" + }; + } + rpc StreamEmptyStream(stream EmptyProto) returns (stream EmptyProto) { + option (google.api.http) = { + post: "/stream/empty/stream" + }; + } - rpc RpcBodyRpc(NonEmptyProto) returns (EmptyProto) { - option (google.api.http) = { - // w/ body; w/o path; w/o query - post: "/rpc/body/rpc" - body: "*" + rpc RpcBodyRpc(NonEmptyProto) returns (EmptyProto) { + option (google.api.http) = { + // w/ body; w/o path; w/o query + post: "/rpc/body/rpc" + body: "*" - // w/o body; w/ path; w/o query - additional_bindings { - post: "/rpc/path/{a}/{b}/{c}/rpc" - } - // w/o body; w/o path; w/ query - additional_bindings { - post: "/rpc/query/rpc" - } - // w/ body; w/ path; w/o query - additional_bindings { - post: "/rpc/body/path/{a}/{b}/rpc" - body: "c" - } - // w/ body; w/o path; w/ query - additional_bindings { - post: "/rpc/body/query/rpc" - body: "c" - } - // w/ body; w/ path; w/ query - additional_bindings { - post: "/rpc/body/path/{a}/query/rpc" - body: "c" - } - // w/o body; w/ path; w/ query - additional_bindings { - post: "/rpc/path/{a}/query/rpc" - } - }; - } - rpc RpcPathSingleNestedRpc(SingleNestedProto) returns (EmptyProto) { - option (google.api.http) = { - // w/o body; w/ path (IsNestedProto3); w/o query - post: "/rpc/path-nested/{a.str}/rpc" - }; - } - rpc RpcPathNestedRpc(NestedProto) returns (EmptyProto) { - option (google.api.http) = { - // w/ body; w/ path (IsNestedProto3); w/o query - post: "/rpc/path-nested/{a.str}/{b}/rpc" - body: "c" + // w/o body; w/ path; w/o query + additional_bindings { + post: "/rpc/path/{a}/{b}/{c}/rpc" + } + // w/o body; w/o path; w/ query + additional_bindings { + post: "/rpc/query/rpc" + } + // w/ body; w/ path; w/o query + additional_bindings { + post: "/rpc/body/path/{a}/{b}/rpc" + body: "c" + } + // w/ body; w/o path; w/ query + additional_bindings { + post: "/rpc/body/query/rpc" + body: "c" + } + // w/ body; w/ path; w/ query + additional_bindings { + post: "/rpc/body/path/{a}/query/rpc" + body: "c" + } + // w/o body; w/ path; w/ query + additional_bindings { + post: "/rpc/path/{a}/query/rpc" + } + }; + } + rpc RpcPathSingleNestedRpc(SingleNestedProto) returns (EmptyProto) { + option (google.api.http) = { + // w/o body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/rpc" + }; + } + rpc RpcPathNestedRpc(NestedProto) returns (EmptyProto) { + option (google.api.http) = { + // w/ body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/{b}/rpc" + body: "c" - // w/o body; w/ path (IsNestedProto3); w/ query - additional_bindings { - post: "/rpc/path-nested1/{a.str}/rpc" - } - // w/ body; w/ path (IsNestedProto3); w/ query - additional_bindings { - post: "/rpc/path-nested2/{a.str}/rpc" - body: "c" - } - }; - } + // w/o body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested1/{a.str}/rpc" + } + // w/ body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested2/{a.str}/rpc" + body: "c" + } + }; + } - rpc RpcBodyStream(NonEmptyProto) returns (stream EmptyProto) { - option (google.api.http) = { - // w/ body; w/o path; w/o query - post: "/rpc/body/stream" - body: "*" + rpc RpcBodyStream(NonEmptyProto) returns (stream EmptyProto) { + option (google.api.http) = { + // w/ body; w/o path; w/o query + post: "/rpc/body/stream" + body: "*" - // w/o body; w/ path; w/o query - additional_bindings { - post: "/rpc/path/{a}/{b}/{c}/stream" - } - // w/o body; w/o path; w/ query - additional_bindings { - post: "/rpc/query/stream" - } - // w/ body; w/ path; w/o query - additional_bindings { - post: "/rpc/body/path/{a}/{b}/stream" - body: "c" - } - // w/ body; w/o path; w/ query - additional_bindings { - post: "/rpc/body/query/stream" - body: "c" - } - // w/ body; w/ path; w/ query - additional_bindings { - post: "/rpc/body/path/{a}/query/stream" - body: "c" - } - // w/o body; w/ path; w/ query - additional_bindings { - post: "/rpc/path/{a}/query/stream" - } - }; - } - rpc RpcPathSingleNestedStream(SingleNestedProto) returns (stream EmptyProto) { - option (google.api.http) = { - // w/o body; w/ path (IsNestedProto3); w/o query - post: "/rpc/path-nested/{a.str}/stream" - }; - } - rpc RpcPathNestedStream(NestedProto) returns (stream EmptyProto) { - option (google.api.http) = { - // w/ body; w/ path (IsNestedProto3); w/o query - post: "/rpc/path-nested/{a.str}/{b}/stream" - body: "c" + // w/o body; w/ path; w/o query + additional_bindings { + post: "/rpc/path/{a}/{b}/{c}/stream" + } + // w/o body; w/o path; w/ query + additional_bindings { + post: "/rpc/query/stream" + } + // w/ body; w/ path; w/o query + additional_bindings { + post: "/rpc/body/path/{a}/{b}/stream" + body: "c" + } + // w/ body; w/o path; w/ query + additional_bindings { + post: "/rpc/body/query/stream" + body: "c" + } + // w/ body; w/ path; w/ query + additional_bindings { + post: "/rpc/body/path/{a}/query/stream" + body: "c" + } + // w/o body; w/ path; w/ query + additional_bindings { + post: "/rpc/path/{a}/query/stream" + } + }; + } + rpc RpcPathSingleNestedStream(SingleNestedProto) returns (stream EmptyProto) { + option (google.api.http) = { + // w/o body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/stream" + }; + } + rpc RpcPathNestedStream(NestedProto) returns (stream EmptyProto) { + option (google.api.http) = { + // w/ body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/{b}/stream" + body: "c" - // w/o body; w/ path (IsNestedProto3); w/ query - additional_bindings { - post: "/rpc/path-nested1/{a.str}/stream" - } - // w/ body; w/ path (IsNestedProto3); w/ query - additional_bindings { - post: "/rpc/path-nested2/{a.str}/stream" - body: "c" - } - }; - } + // w/o body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested1/{a.str}/stream" + } + // w/ body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested2/{a.str}/stream" + body: "c" + } + }; + } } diff --git a/examples/internal/proto/examplepb/generate_unbound_methods.proto b/examples/internal/proto/examplepb/generate_unbound_methods.proto index 1c67993a2dc..51bb21f3962 100644 --- a/examples/internal/proto/examplepb/generate_unbound_methods.proto +++ b/examples/internal/proto/examplepb/generate_unbound_methods.proto @@ -1,5 +1,4 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Generate Unannotated Methods Echo Service // Similar to echo_service.proto but without annotations and without external configuration. @@ -11,25 +10,27 @@ package grpc.gateway.examples.internal.proto.examplepb; // Do not need annotations.proto, can still use well known types as usual import "google/protobuf/duration.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + // GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. message GenerateUnboundMethodsSimpleMessage { - // Id represents the message identifier. - string id = 1; - int64 num = 2; - google.protobuf.Duration duration = 3; + // Id represents the message identifier. + string id = 1; + int64 num = 2; + google.protobuf.Duration duration = 3; } // GenerateUnboundMethodsEchoService service responds to incoming echo requests. service GenerateUnboundMethodsEchoService { - // Echo method receives a simple message and returns it. - // - // The message posted as the id parameter will also be - // returned. - rpc Echo(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); + // Echo method receives a simple message and returns it. + // + // The message posted as the id parameter will also be + // returned. + rpc Echo(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); + + // EchoBody method receives a simple message and returns it. + rpc EchoBody(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); - // EchoBody method receives a simple message and returns it. - rpc EchoBody(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); - - // EchoDelete method receives a simple message and returns it. - rpc EchoDelete(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); + // EchoDelete method receives a simple message and returns it. + rpc EchoDelete(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); } diff --git a/examples/internal/proto/examplepb/generated_input.proto b/examples/internal/proto/examplepb/generated_input.proto index bd4ab5fb247..2bda2e7b1bf 100644 --- a/examples/internal/proto/examplepb/generated_input.proto +++ b/examples/internal/proto/examplepb/generated_input.proto @@ -1,20 +1,21 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; +import "examples/internal/proto/examplepb/a_bit_of_everything.proto"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; -import "examples/internal/proto/examplepb/a_bit_of_everything.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // This file is run through a genrule. // Defines some more operations to be added to ABitOfEverythingService service GeneratedService { - rpc Create(ABitOfEverything) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/example/a_bit_of_everything/generated_create" - body: "*" - }; - } - + rpc Create(ABitOfEverything) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/example/a_bit_of_everything/generated_create" + body: "*" + }; + } } diff --git a/examples/internal/proto/examplepb/non_standard_names.proto b/examples/internal/proto/examplepb/non_standard_names.proto index 1a1a76d1378..3b40cf9f49e 100644 --- a/examples/internal/proto/examplepb/non_standard_names.proto +++ b/examples/internal/proto/examplepb/non_standard_names.proto @@ -1,75 +1,77 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + // NonStandardMessage has oddly named fields. message NonStandardMessage { - // Id represents the message identifier. - string id = 1; - int64 Num = 2; - int64 line_num = 3; - string langIdent = 4; - string STATUS = 5; - int64 en_GB = 6; - string no = 7; + // Id represents the message identifier. + string id = 1; + int64 Num = 2; + int64 line_num = 3; + string langIdent = 4; + string STATUS = 5; + int64 en_GB = 6; + string no = 7; - message Thing { - message SubThing { - string sub_value = 1; - } - SubThing subThing = 1; + message Thing { + message SubThing { + string sub_value = 1; } - Thing thing = 8; + SubThing subThing = 1; + } + Thing thing = 8; } message NonStandardUpdateRequest { - NonStandardMessage body = 1; - google.protobuf.FieldMask update_mask = 2; + NonStandardMessage body = 1; + google.protobuf.FieldMask update_mask = 2; } // NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion. message NonStandardMessageWithJSONNames { - // Id represents the message identifier. - string id = 1 [json_name="ID"]; - int64 Num = 2 [json_name="Num"]; - int64 line_num = 3 [json_name="LineNum"]; - string langIdent = 4 [json_name="langIdent"]; - string STATUS = 5 [json_name="status"]; - int64 en_GB = 6 [json_name="En_GB"]; - string no = 7 [json_name="yes"]; + // Id represents the message identifier. + string id = 1 [json_name = "ID"]; + int64 Num = 2 [json_name = "Num"]; + int64 line_num = 3 [json_name = "LineNum"]; + string langIdent = 4 [json_name = "langIdent"]; + string STATUS = 5 [json_name = "status"]; + int64 en_GB = 6 [json_name = "En_GB"]; + string no = 7 [json_name = "yes"]; - message Thing { - message SubThing { - string sub_value = 1 [json_name="sub_Value"]; - } - SubThing subThing = 1 [json_name="SubThing"]; + message Thing { + message SubThing { + string sub_value = 1 [json_name = "sub_Value"]; } - Thing thing = 8 [json_name="Thingy"]; + SubThing subThing = 1 [json_name = "SubThing"]; + } + Thing thing = 8 [json_name = "Thingy"]; } message NonStandardWithJSONNamesUpdateRequest { - NonStandardMessageWithJSONNames body = 1; - google.protobuf.FieldMask update_mask = 2; + NonStandardMessageWithJSONNames body = 1; + google.protobuf.FieldMask update_mask = 2; } // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. service NonStandardService { - // Apply field mask to empty NonStandardMessage and return result. - rpc Update(NonStandardUpdateRequest) returns (NonStandardMessage) { - option (google.api.http) = { - patch: "/v1/example/non_standard/update" - body: "body" - }; - } + // Apply field mask to empty NonStandardMessage and return result. + rpc Update(NonStandardUpdateRequest) returns (NonStandardMessage) { + option (google.api.http) = { + patch: "/v1/example/non_standard/update" + body: "body" + }; + } - // Apply field mask to empty NonStandardMessageWithJSONNames and return result. - rpc UpdateWithJSONNames(NonStandardWithJSONNamesUpdateRequest) returns (NonStandardMessageWithJSONNames) { - option (google.api.http) = { - patch: "/v1/example/non_standard/update_with_json_names" - body: "body" - }; - } + // Apply field mask to empty NonStandardMessageWithJSONNames and return result. + rpc UpdateWithJSONNames(NonStandardWithJSONNamesUpdateRequest) returns (NonStandardMessageWithJSONNames) { + option (google.api.http) = { + patch: "/v1/example/non_standard/update_with_json_names" + body: "body" + }; + } } diff --git a/examples/internal/proto/examplepb/openapi_merge_a.proto b/examples/internal/proto/examplepb/openapi_merge_a.proto index 007ecd70031..de4f7c52802 100644 --- a/examples/internal/proto/examplepb/openapi_merge_a.proto +++ b/examples/internal/proto/examplepb/openapi_merge_a.proto @@ -1,7 +1,5 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; - // Merging Services // // This is an example of merging two proto files. @@ -9,6 +7,8 @@ package grpc.gateway.examples.internal.examplepb; import "google/api/annotations.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + // InMessageA represents a message to ServiceA and ServiceC. message InMessageA { // Here is the explanation about InMessageA.values diff --git a/examples/internal/proto/examplepb/openapi_merge_b.proto b/examples/internal/proto/examplepb/openapi_merge_b.proto index 0be7b3e62d9..8390a23f4f9 100644 --- a/examples/internal/proto/examplepb/openapi_merge_b.proto +++ b/examples/internal/proto/examplepb/openapi_merge_b.proto @@ -1,7 +1,5 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; - // Merging Services // // This is an example of merging two proto files. @@ -9,36 +7,38 @@ package grpc.gateway.examples.internal.examplepb; import "google/api/annotations.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + // InMessageB represents a message to ServiceB. message InMessageB { - // Here is the explanation about InMessageB.values - string value = 1; + // Here is the explanation about InMessageB.values + string value = 1; } // OutMessageB represents a message returned from ServiceB. message OutMessageB { - // Here is the explanation about OutMessageB.value - repeated string values = 1; + // Here is the explanation about OutMessageB.value + repeated string values = 1; } // ServiceB service responds to incoming merge requests. service ServiceB { - // ServiceB.MethodOne receives InMessageB and returns OutMessageB - // - // Here is the detail explanation about ServiceB.MethodOne. - rpc MethodOne(InMessageB) returns (OutMessageB) { - option (google.api.http) = { + // ServiceB.MethodOne receives InMessageB and returns OutMessageB + // + // Here is the detail explanation about ServiceB.MethodOne. + rpc MethodOne(InMessageB) returns (OutMessageB) { + option (google.api.http) = { post: "/v1/example/b/1" body: "*" - }; - } - // ServiceB.MethodTwo receives OutMessageB and returns InMessageB - // - // Here is the detail explanation about ServiceB.MethodTwo. - rpc MethodTwo(OutMessageB) returns (InMessageB) { - option (google.api.http) = { + }; + } + // ServiceB.MethodTwo receives OutMessageB and returns InMessageB + // + // Here is the detail explanation about ServiceB.MethodTwo. + rpc MethodTwo(OutMessageB) returns (InMessageB) { + option (google.api.http) = { post: "/v1/example/b/2" body: "*" - }; - } + }; + } } diff --git a/examples/internal/proto/examplepb/response_body_service.proto b/examples/internal/proto/examplepb/response_body_service.proto index 9153b27f62b..31480f8341d 100644 --- a/examples/internal/proto/examplepb/response_body_service.proto +++ b/examples/internal/proto/examplepb/response_body_service.proto @@ -1,65 +1,66 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + message ResponseBodyIn { - string data = 1; + string data = 1; } message ResponseBodyOut { - message Response { - string data = 1; - } - Response response = 2; + message Response { + string data = 1; + } + Response response = 2; } message RepeatedResponseBodyOut { - message Response { - string data = 1; - enum ResponseType { - // UNKNOWN - UNKNOWN = 0; - // A is 1 - A = 1; - // B is 2 - B = 2; - } - ResponseType type = 3; - } - repeated Response response = 2; + message Response { + string data = 1; + enum ResponseType { + // UNKNOWN + UNKNOWN = 0; + // A is 1 + A = 1; + // B is 2 + B = 2; + } + ResponseType type = 3; + } + repeated Response response = 2; } message RepeatedResponseStrings { - repeated string values = 1; + repeated string values = 1; } service ResponseBodyService { - rpc GetResponseBody(ResponseBodyIn) returns (ResponseBodyOut) { - option (google.api.http) = { - get : "/responsebody/{data}" - response_body : "response" - }; - } - rpc ListResponseBodies(ResponseBodyIn) returns (RepeatedResponseBodyOut) { - option (google.api.http) = { - get : "/responsebodies/{data}" - response_body : "response" - }; - } - rpc ListResponseStrings(ResponseBodyIn) returns (RepeatedResponseStrings) { - option (google.api.http) = { - get : "/responsestrings/{data}" - response_body : "values" - }; - } + rpc GetResponseBody(ResponseBodyIn) returns (ResponseBodyOut) { + option (google.api.http) = { + get: "/responsebody/{data}" + response_body: "response" + }; + } + rpc ListResponseBodies(ResponseBodyIn) returns (RepeatedResponseBodyOut) { + option (google.api.http) = { + get: "/responsebodies/{data}" + response_body: "response" + }; + } + rpc ListResponseStrings(ResponseBodyIn) returns (RepeatedResponseStrings) { + option (google.api.http) = { + get: "/responsestrings/{data}" + response_body: "values" + }; + } - rpc GetResponseBodyStream(ResponseBodyIn) returns (stream ResponseBodyOut) { - option (google.api.http) = { - get : "/responsebody/stream/{data}" - response_body : "response" - }; - } + rpc GetResponseBodyStream(ResponseBodyIn) returns (stream ResponseBodyOut) { + option (google.api.http) = { + get: "/responsebody/stream/{data}" + response_body: "response" + }; + } } diff --git a/examples/internal/proto/examplepb/stream.pb.go b/examples/internal/proto/examplepb/stream.pb.go index 6d1c2ef1750..ff9c0d54747 100644 --- a/examples/internal/proto/examplepb/stream.pb.go +++ b/examples/internal/proto/examplepb/stream.pb.go @@ -32,18 +32,18 @@ var file_examples_internal_proto_examplepb_stream_proto_rawDesc = []byte{ 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, - 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, - 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, - 0x6f, 0x64, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, - 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, - 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xc7, + 0x1a, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x70, 0x62, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, + 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x29, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xc7, 0x04, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x99, 0x01, 0x0a, 0x0a, 0x42, 0x75, 0x6c, 0x6b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, diff --git a/examples/internal/proto/examplepb/stream.proto b/examples/internal/proto/examplepb/stream.proto index beeae591eee..72f03a12803 100644 --- a/examples/internal/proto/examplepb/stream.proto +++ b/examples/internal/proto/examplepb/stream.proto @@ -1,36 +1,38 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; +import "examples/internal/proto/examplepb/a_bit_of_everything.proto"; +import "examples/internal/proto/sub/message.proto"; import "google/api/annotations.proto"; import "google/api/httpbody.proto"; import "google/protobuf/empty.proto"; -import "examples/internal/proto/examplepb/a_bit_of_everything.proto"; -import "examples/internal/proto/sub/message.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Defines some more operations to be added to ABitOfEverythingService service StreamService { - rpc BulkCreate(stream ABitOfEverything) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/example/a_bit_of_everything/bulk" - body: "*" - }; - } - rpc List(google.protobuf.Empty) returns (stream ABitOfEverything) { - option (google.api.http) = { - get: "/v1/example/a_bit_of_everything" - }; - } - rpc BulkEcho(stream grpc.gateway.examples.internal.proto.sub.StringMessage) returns (stream grpc.gateway.examples.internal.proto.sub.StringMessage) { - option (google.api.http) = { - post: "/v1/example/a_bit_of_everything/echo" - body: "*" - }; - } + rpc BulkCreate(stream ABitOfEverything) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/example/a_bit_of_everything/bulk" + body: "*" + }; + } + rpc List(google.protobuf.Empty) returns (stream ABitOfEverything) { + option (google.api.http) = { + get: "/v1/example/a_bit_of_everything" + }; + } + rpc BulkEcho(stream grpc.gateway.examples.internal.proto.sub.StringMessage) returns (stream grpc.gateway.examples.internal.proto.sub.StringMessage) { + option (google.api.http) = { + post: "/v1/example/a_bit_of_everything/echo" + body: "*" + }; + } - rpc Download(google.protobuf.Empty) returns (stream google.api.HttpBody) { - option (google.api.http) = { - get : "/v1/example/download" - }; - } + rpc Download(google.protobuf.Empty) returns (stream google.api.HttpBody) { + option (google.api.http) = { + get: "/v1/example/download" + }; + } } diff --git a/examples/internal/proto/examplepb/unannotated_echo_service.proto b/examples/internal/proto/examplepb/unannotated_echo_service.proto index cbe0f375257..fc8fbadb97d 100644 --- a/examples/internal/proto/examplepb/unannotated_echo_service.proto +++ b/examples/internal/proto/examplepb/unannotated_echo_service.proto @@ -1,5 +1,4 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb"; // Unannotated Echo Service // Similar to echo_service.proto but without annotations. See @@ -13,42 +12,44 @@ package grpc.gateway.examples.internal.proto.examplepb; // Do not need annotations.proto, can still use well known types as usual import "google/protobuf/duration.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb"; + // Embedded represents a message embedded in SimpleMessage. message UnannotatedEmbedded { - oneof mark { - int64 progress = 1; - string note = 2; - } + oneof mark { + int64 progress = 1; + string note = 2; + } } // UnannotatedSimpleMessage represents a simple message sent to the unannotated Echo service. message UnannotatedSimpleMessage { - // Id represents the message identifier. - string id = 1; - int64 num = 2; - google.protobuf.Duration duration = 3; - oneof code { - int64 line_num = 4; - string lang = 5; - } - UnannotatedEmbedded status = 6; - oneof ext { - int64 en = 7; - UnannotatedEmbedded no = 8; - } + // Id represents the message identifier. + string id = 1; + int64 num = 2; + google.protobuf.Duration duration = 3; + oneof code { + int64 line_num = 4; + string lang = 5; + } + UnannotatedEmbedded status = 6; + oneof ext { + int64 en = 7; + UnannotatedEmbedded no = 8; + } } // Echo service responds to incoming echo requests. service UnannotatedEchoService { - // Echo method receives a simple message and returns it. - // - // The message posted as the id parameter will also be - // returned. - rpc Echo(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); - - // EchoBody method receives a simple message and returns it. - rpc EchoBody(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); - - // EchoDelete method receives a simple message and returns it. - rpc EchoDelete(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); + // Echo method receives a simple message and returns it. + // + // The message posted as the id parameter will also be + // returned. + rpc Echo(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); + + // EchoBody method receives a simple message and returns it. + rpc EchoBody(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); + + // EchoDelete method receives a simple message and returns it. + rpc EchoDelete(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); } diff --git a/examples/internal/proto/examplepb/use_go_template.proto b/examples/internal/proto/examplepb/use_go_template.proto index dc11abe1342..250e8c1ab32 100644 --- a/examples/internal/proto/examplepb/use_go_template.proto +++ b/examples/internal/proto/examplepb/use_go_template.proto @@ -1,85 +1,87 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + service LoginService { - // Login - // - // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. - // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". - // - // ## {{.RequestType.Name}} - // | Field ID | Name | Type | Description | - // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} - // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} - // - // ## {{.ResponseType.Name}} - // | Field ID | Name | Type | Description | - // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} - // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} - rpc Login (LoginRequest) returns (LoginReply) { - option (google.api.http) = { - post: "/v1/example/login" - body: "*" - }; - } + // Login + // + // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. + // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". + // + // ## {{.RequestType.Name}} + // | Field ID | Name | Type | Description | + // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} + // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} + // + // ## {{.ResponseType.Name}} + // | Field ID | Name | Type | Description | + // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} + // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} + rpc Login(LoginRequest) returns (LoginReply) { + option (google.api.http) = { + post: "/v1/example/login" + body: "*" + }; + } - // Logout - // - // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. - // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". - // - // ## {{.RequestType.Name}} - // | Field ID | Name | Type | Description | - // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} - // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} - // - // ## {{.ResponseType.Name}} - // | Field ID | Name | Type | Description | - // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} - // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} - rpc Logout (LogoutRequest) returns (LogoutReply) { - option (google.api.http) = { - post: "/v1/example/logout" - body: "*" - }; - } + // Logout + // + // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. + // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". + // + // ## {{.RequestType.Name}} + // | Field ID | Name | Type | Description | + // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} + // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} + // + // ## {{.ResponseType.Name}} + // | Field ID | Name | Type | Description | + // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} + // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} + rpc Logout(LogoutRequest) returns (LogoutReply) { + option (google.api.http) = { + post: "/v1/example/logout" + body: "*" + }; + } } message LoginRequest { - // The entered username - string username = 1; - // The entered password - string password = 2; + // The entered username + string username = 1; + // The entered password + string password = 2; } message LoginReply { - string message = 1; - // Whether you have access or not - bool access = 2; + string message = 1; + // Whether you have access or not + bool access = 2; } message LogoutRequest { - // The time the logout was registered - string timeoflogout = 1; - // This is the title - // - // This is the "Description" of field test - // you can use as many newlines as you want - // - // - // it will still format the same in the table - int32 test = 2; - // This is an array - // - // It displays that using [] infront of the type - repeated string stringarray = 3; + // The time the logout was registered + string timeoflogout = 1; + // This is the title + // + // This is the "Description" of field test + // you can use as many newlines as you want + // + // + // it will still format the same in the table + int32 test = 2; + // This is an array + // + // It displays that using [] infront of the type + repeated string stringarray = 3; } message LogoutReply { - // Message that tells you whether your - // logout was succesful or not - string message = 1; + // Message that tells you whether your + // logout was succesful or not + string message = 1; } diff --git a/examples/internal/proto/examplepb/use_go_template.swagger.json b/examples/internal/proto/examplepb/use_go_template.swagger.json index 90881b9ffc5..d34b85eb0cc 100644 --- a/examples/internal/proto/examplepb/use_go_template.swagger.json +++ b/examples/internal/proto/examplepb/use_go_template.swagger.json @@ -19,7 +19,7 @@ "/v1/example/login": { "post": { "summary": "Login", - "description": "Login is a call with the method(s) POST within the \"LoginService\" service.\nIt takes in \"LoginRequest\" and returns a \"LoginReply\".\n\n## LoginRequest\n| Field ID | Name | Type | Description |\n| ----------- | --------- | --------------------------------------------------------- | ---------------------------- | \n| 1 | username | TYPE_STRING | The entered username | \n| 2 | password | TYPE_STRING | The entered password | \n\n## LoginReply\n| Field ID | Name | Type | Description |\n| ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | \n| 1 | message | TYPE_STRING | | \n| 2 | access | TYPE_BOOL | Whether you have access or not |", + "description": "Login is a call with the method(s) POST within the \"LoginService\" service.\nIt takes in \"LoginRequest\" and returns a \"LoginReply\".\n\n## LoginRequest\n| Field ID | Name | Type | Description |\n| ----------- | --------- | --------------------------------------------------------- | ---------------------------- | \n| 1 | username | TYPE_STRING | The entered username | \n| 2 | password | TYPE_STRING | The entered password | \n\n## LoginReply\n| Field ID | Name | Type | Description |\n| ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | \n| 1 | message | TYPE_STRING | | \n| 2 | access | TYPE_BOOL | Whether you have access or not |", "operationId": "LoginService_Login", "responses": { "200": { @@ -53,7 +53,7 @@ "/v1/example/logout": { "post": { "summary": "Logout", - "description": "Logout is a call with the method(s) POST within the \"LoginService\" service.\nIt takes in \"LogoutRequest\" and returns a \"LogoutReply\".\n\n## LogoutRequest\n| Field ID | Name | Type | Description |\n| ----------- | --------- | --------------------------------------------------------- | ---------------------------- | \n| 1 | timeoflogout | TYPE_STRING | The time the logout was registered | \n| 2 | test | TYPE_INT32 | This is the title\u003cbr\u003e\u003cbr\u003eThis is the \"Description\" of field test\u003cbr\u003eyou can use as many newlines as you want\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eit will still format the same in the table | \n| 3 | stringarray | []TYPE_STRING | This is an array\u003cbr\u003e\u003cbr\u003eIt displays that using [] infront of the type | \n\n## LogoutReply\n| Field ID | Name | Type | Description |\n| ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | \n| 1 | message | TYPE_STRING | Message that tells you whether your\u003cbr\u003elogout was succesful or not |", + "description": "Logout is a call with the method(s) POST within the \"LoginService\" service.\nIt takes in \"LogoutRequest\" and returns a \"LogoutReply\".\n\n## LogoutRequest\n| Field ID | Name | Type | Description |\n| ----------- | --------- | --------------------------------------------------------- | ---------------------------- | \n| 1 | timeoflogout | TYPE_STRING | The time the logout was registered | \n| 2 | test | TYPE_INT32 | This is the title\u003cbr\u003e\u003cbr\u003eThis is the \"Description\" of field test\u003cbr\u003eyou can use as many newlines as you want\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eit will still format the same in the table | \n| 3 | stringarray | []TYPE_STRING | This is an array\u003cbr\u003e\u003cbr\u003eIt displays that using [] infront of the type | \n\n## LogoutReply\n| Field ID | Name | Type | Description |\n| ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | \n| 1 | message | TYPE_STRING | Message that tells you whether your\u003cbr\u003elogout was succesful or not |", "operationId": "LoginService_Logout", "responses": { "200": { diff --git a/examples/internal/proto/examplepb/visibility_rule_echo_service.proto b/examples/internal/proto/examplepb/visibility_rule_echo_service.proto index 9b14f5ad1f0..7aa78470b88 100644 --- a/examples/internal/proto/examplepb/visibility_rule_echo_service.proto +++ b/examples/internal/proto/examplepb/visibility_rule_echo_service.proto @@ -1,5 +1,4 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb"; // Visibility Rule Echo Service // Similar to echo_service.proto but with annotations to change visibility @@ -16,40 +15,42 @@ package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "google/api/visibility.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb"; + // Embedded represents a message embedded in SimpleMessage. message VisibilityRuleEmbedded { - oneof mark { - int64 progress = 1; - string note = 2; - string internal_field = 3 [(google.api.field_visibility).restriction = "INTERNAL"]; - string preview_field = 4 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; - } + oneof mark { + int64 progress = 1; + string note = 2; + string internal_field = 3 [(google.api.field_visibility).restriction = "INTERNAL"]; + string preview_field = 4 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; + } } // SimpleMessage represents a simple message sent to the Echo service. message VisibilityRuleSimpleMessage { - enum VisibilityEnum { - VISIBILITY_ENUM_UNSPECIFIED = 0; - VISIBILITY_ENUM_VISIBLE = 1; - VISIBILITY_ENUM_INTERNAL = 2 [(google.api.value_visibility).restriction = "INTERNAL"]; - VISIBILITY_ENUM_PREVIEW = 3 [(google.api.value_visibility).restriction = "INTERNAL,PREVIEW"]; - } + enum VisibilityEnum { + VISIBILITY_ENUM_UNSPECIFIED = 0; + VISIBILITY_ENUM_VISIBLE = 1; + VISIBILITY_ENUM_INTERNAL = 2 [(google.api.value_visibility).restriction = "INTERNAL"]; + VISIBILITY_ENUM_PREVIEW = 3 [(google.api.value_visibility).restriction = "INTERNAL,PREVIEW"]; + } - // Id represents the message identifier. - string id = 1; - int64 num = 2; - oneof code { - int64 line_num = 3; - string lang = 4; - } - VisibilityRuleEmbedded status = 5; - oneof ext { - int64 en = 6; - VisibilityRuleEmbedded no = 7; - } - string internal_field = 8 [(google.api.field_visibility).restriction = "INTERNAL"]; - string preview_field = 9 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; - VisibilityEnum an_enum = 10; + // Id represents the message identifier. + string id = 1; + int64 num = 2; + oneof code { + int64 line_num = 3; + string lang = 4; + } + VisibilityRuleEmbedded status = 5; + oneof ext { + int64 en = 6; + VisibilityRuleEmbedded no = 7; + } + string internal_field = 8 [(google.api.field_visibility).restriction = "INTERNAL"]; + string preview_field = 9 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; + VisibilityEnum an_enum = 10; } // VisibilityRuleEchoService service responds to incoming echo requests. @@ -57,49 +58,49 @@ message VisibilityRuleSimpleMessage { // based on `google.api.VisibilityRule`s and the set `visibility_restriction_selectors` // flag when calling protoc-gen-openapiv2. service VisibilityRuleEchoService { - // Echo method receives a simple message and returns it. - // It should always be visible in the open API output. - rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { - option (google.api.http) = { - post: "/v1/example/echo/{id}" - }; - } - // EchoInternal is an internal API that should only be visible in the OpenAPI spec - // if `visibility_restriction_selectors` includes "INTERNAL". - rpc EchoInternal(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { - option (google.api.method_visibility).restriction = "INTERNAL"; - option (google.api.http) = { - get: "/v1/example/echo_internal" - }; - } - // EchoPreview is a preview API that should only be visible in the OpenAPI spec - // if `visibility_restriction_selectors` includes "PREVIEW". - rpc EchoPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { - option (google.api.method_visibility).restriction = "PREVIEW"; - option (google.api.http) = { - get: "/v1/example/echo_preview" - }; - } - // EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec - // if `visibility_restriction_selectors` includes "PREVIEW" or "INTERNAL". - rpc EchoInternalAndPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { - option (google.api.method_visibility).restriction = "INTERNAL,PREVIEW"; - option (google.api.http) = { - get: "/v1/example/echo_internal_and_preview" - }; - } + // Echo method receives a simple message and returns it. + // It should always be visible in the open API output. + rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { + option (google.api.http) = { + post: "/v1/example/echo/{id}" + }; + } + // EchoInternal is an internal API that should only be visible in the OpenAPI spec + // if `visibility_restriction_selectors` includes "INTERNAL". + rpc EchoInternal(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { + option (google.api.method_visibility).restriction = "INTERNAL"; + option (google.api.http) = { + get: "/v1/example/echo_internal" + }; + } + // EchoPreview is a preview API that should only be visible in the OpenAPI spec + // if `visibility_restriction_selectors` includes "PREVIEW". + rpc EchoPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { + option (google.api.method_visibility).restriction = "PREVIEW"; + option (google.api.http) = { + get: "/v1/example/echo_preview" + }; + } + // EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec + // if `visibility_restriction_selectors` includes "PREVIEW" or "INTERNAL". + rpc EchoInternalAndPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { + option (google.api.method_visibility).restriction = "INTERNAL,PREVIEW"; + option (google.api.http) = { + get: "/v1/example/echo_internal_and_preview" + }; + } } // VisibilityRuleInternalEchoService service responds to incoming echo requests. // It should only be visible in the OpenAPI spec if `visibility_restriction_selectors` includes "INTERNAL". service VisibilityRuleInternalEchoService { - option (google.api.api_visibility).restriction = "INTERNAL"; + option (google.api.api_visibility).restriction = "INTERNAL"; - // Echo method receives a simple message and returns it. - // It should not be visible in the open API output. - rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { - option (google.api.http) = { - post: "/v1/example/internal/echo/{id}" - }; - } + // Echo method receives a simple message and returns it. + // It should not be visible in the open API output. + rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { + option (google.api.http) = { + post: "/v1/example/internal/echo/{id}" + }; + } } diff --git a/examples/internal/proto/examplepb/wrappers.pb.go b/examples/internal/proto/examplepb/wrappers.pb.go index aef3c3ac2d7..8803cd7707a 100644 --- a/examples/internal/proto/examplepb/wrappers.pb.go +++ b/examples/internal/proto/examplepb/wrappers.pb.go @@ -145,10 +145,10 @@ var file_examples_internal_proto_examplepb_wrappers_proto_rawDesc = []byte{ 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc1, 0x04, + 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, + 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc1, 0x04, 0x0a, 0x08, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, diff --git a/examples/internal/proto/examplepb/wrappers.proto b/examples/internal/proto/examplepb/wrappers.proto index 6ba2c6a0bd9..dcbd9d878ec 100644 --- a/examples/internal/proto/examplepb/wrappers.proto +++ b/examples/internal/proto/examplepb/wrappers.proto @@ -1,89 +1,91 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; -import "google/protobuf/wrappers.proto"; import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; message Wrappers { - google.protobuf.StringValue string_value = 1; - google.protobuf.Int32Value int32_value = 2; - google.protobuf.Int64Value int64_value = 3; - google.protobuf.FloatValue float_value = 4; - google.protobuf.DoubleValue double_value = 5; - google.protobuf.BoolValue bool_value = 6; - google.protobuf.UInt32Value uint32_value = 7; - google.protobuf.UInt64Value uint64_value = 8; - google.protobuf.BytesValue bytes_value = 9; + google.protobuf.StringValue string_value = 1; + google.protobuf.Int32Value int32_value = 2; + google.protobuf.Int64Value int64_value = 3; + google.protobuf.FloatValue float_value = 4; + google.protobuf.DoubleValue double_value = 5; + google.protobuf.BoolValue bool_value = 6; + google.protobuf.UInt32Value uint32_value = 7; + google.protobuf.UInt64Value uint64_value = 8; + google.protobuf.BytesValue bytes_value = 9; } service WrappersService { - rpc Create(Wrappers) returns (Wrappers) { - option (google.api.http) = { - post: "/v1/example/wrappers" - body: "*" - }; - } + rpc Create(Wrappers) returns (Wrappers) { + option (google.api.http) = { + post: "/v1/example/wrappers" + body: "*" + }; + } - rpc CreateStringValue(google.protobuf.StringValue) returns (google.protobuf.StringValue) { - option (google.api.http) = { - post: "/v1/testString" - body: "*" - }; - } - rpc CreateInt32Value(google.protobuf.Int32Value) returns (google.protobuf.Int32Value) { - option (google.api.http) = { - post: "/v1/testInt32" - body: "*" - }; - } - rpc CreateInt64Value(google.protobuf.Int64Value) returns (google.protobuf.Int64Value){ - option (google.api.http) = { - post: "/v1/testInt64" - body: "*" - }; - } - rpc CreateFloatValue(google.protobuf.FloatValue) returns (google.protobuf.FloatValue){ - option (google.api.http) = { - post: "/v1/testFloat" - body: "*" - }; - } - rpc CreateDoubleValue(google.protobuf.DoubleValue) returns (google.protobuf.DoubleValue){ - option (google.api.http) = { - post: "/v1/testDouble" - body: "*" - }; - } - rpc CreateBoolValue(google.protobuf.BoolValue) returns (google.protobuf.BoolValue){ - option (google.api.http) = { - post: "/v1/testBool" - body: "*" - }; - } - rpc CreateUInt32Value(google.protobuf.UInt32Value) returns (google.protobuf.UInt32Value){ - option (google.api.http) = { - post: "/v1/testUint32" - body: "*" - }; - } - rpc CreateUInt64Value(google.protobuf.UInt64Value) returns (google.protobuf.UInt64Value){ - option (google.api.http) = { - post: "/v1/testUint64" - body: "*" - }; - } - rpc CreateBytesValue(google.protobuf.BytesValue) returns (google.protobuf.BytesValue){ - option (google.api.http) = { - post: "/v1/testBytes" - body: "*" - }; - } - rpc CreateEmpty(google.protobuf.Empty) returns (google.protobuf.Empty){ - option (google.api.http) = { - post: "/v1/testEmpty" - body: "*" - }; - } + rpc CreateStringValue(google.protobuf.StringValue) returns (google.protobuf.StringValue) { + option (google.api.http) = { + post: "/v1/testString" + body: "*" + }; + } + rpc CreateInt32Value(google.protobuf.Int32Value) returns (google.protobuf.Int32Value) { + option (google.api.http) = { + post: "/v1/testInt32" + body: "*" + }; + } + rpc CreateInt64Value(google.protobuf.Int64Value) returns (google.protobuf.Int64Value) { + option (google.api.http) = { + post: "/v1/testInt64" + body: "*" + }; + } + rpc CreateFloatValue(google.protobuf.FloatValue) returns (google.protobuf.FloatValue) { + option (google.api.http) = { + post: "/v1/testFloat" + body: "*" + }; + } + rpc CreateDoubleValue(google.protobuf.DoubleValue) returns (google.protobuf.DoubleValue) { + option (google.api.http) = { + post: "/v1/testDouble" + body: "*" + }; + } + rpc CreateBoolValue(google.protobuf.BoolValue) returns (google.protobuf.BoolValue) { + option (google.api.http) = { + post: "/v1/testBool" + body: "*" + }; + } + rpc CreateUInt32Value(google.protobuf.UInt32Value) returns (google.protobuf.UInt32Value) { + option (google.api.http) = { + post: "/v1/testUint32" + body: "*" + }; + } + rpc CreateUInt64Value(google.protobuf.UInt64Value) returns (google.protobuf.UInt64Value) { + option (google.api.http) = { + post: "/v1/testUint64" + body: "*" + }; + } + rpc CreateBytesValue(google.protobuf.BytesValue) returns (google.protobuf.BytesValue) { + option (google.api.http) = { + post: "/v1/testBytes" + body: "*" + }; + } + rpc CreateEmpty(google.protobuf.Empty) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/testEmpty" + body: "*" + }; + } } diff --git a/examples/internal/proto/pathenum/path_enum.proto b/examples/internal/proto/pathenum/path_enum.proto index a8219949b32..fc70ac6a645 100644 --- a/examples/internal/proto/pathenum/path_enum.proto +++ b/examples/internal/proto/pathenum/path_enum.proto @@ -1,23 +1,25 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum"; + package grpc.gateway.examples.internal.pathenum; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum"; + enum PathEnum { - ABC = 0; - DEF = 1; + ABC = 0; + DEF = 1; } message MessagePathEnum { - enum NestedPathEnum { - GHI = 0; - JKL = 1; - } + enum NestedPathEnum { + GHI = 0; + JKL = 1; + } } message MessageWithPathEnum { - PathEnum value = 1; + PathEnum value = 1; } message MessageWithNestedPathEnum { - MessagePathEnum.NestedPathEnum value = 1; + MessagePathEnum.NestedPathEnum value = 1; } diff --git a/examples/internal/proto/sub/message.proto b/examples/internal/proto/sub/message.proto index 32768345c79..7b83d406c02 100644 --- a/examples/internal/proto/sub/message.proto +++ b/examples/internal/proto/sub/message.proto @@ -1,7 +1,9 @@ syntax = "proto2"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub"; + package grpc.gateway.examples.internal.proto.sub; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub"; + message StringMessage { - required string value = 1; + required string value = 1; } diff --git a/examples/internal/proto/sub2/message.proto b/examples/internal/proto/sub2/message.proto index 5ddbbaa1bc4..8c4c0f12e7d 100644 --- a/examples/internal/proto/sub2/message.proto +++ b/examples/internal/proto/sub2/message.proto @@ -1,7 +1,9 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2"; + package grpc.gateway.examples.internal.proto.sub2; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2"; + message IdMessage { - string uuid = 1; + string uuid = 1; } diff --git a/internal/descriptor/apiconfig/apiconfig.proto b/internal/descriptor/apiconfig/apiconfig.proto index aeecd777384..b7379dcd8d2 100644 --- a/internal/descriptor/apiconfig/apiconfig.proto +++ b/internal/descriptor/apiconfig/apiconfig.proto @@ -2,10 +2,10 @@ syntax = "proto3"; package grpc.gateway.internal.descriptor.apiconfig; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig"; - import "google/api/http.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig"; + // GrpcAPIService represents a stripped down version of google.api.Service . // Compare to https://github.com/googleapis/googleapis/blob/master/google/api/service.proto // The original imports 23 other protobuf files we are not interested in. If a significant @@ -16,6 +16,6 @@ import "google/api/http.proto"; // available features google supports in their service descriptions. Thanks to backwards // compatibility guarantees by protobuf it is safe for us to remove the other fields. message GrpcAPIService { - // Http Rule. - google.api.Http http = 1; + // Http Rule. + google.api.Http http = 1; } diff --git a/internal/descriptor/openapiconfig/openapiconfig.proto b/internal/descriptor/openapiconfig/openapiconfig.proto index f0aa69ee295..17cf86a90c8 100644 --- a/internal/descriptor/openapiconfig/openapiconfig.proto +++ b/internal/descriptor/openapiconfig/openapiconfig.proto @@ -2,50 +2,50 @@ syntax = "proto3"; package grpc.gateway.internal.descriptor.openapiconfig; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig"; - import "protoc-gen-openapiv2/options/openapiv2.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig"; + // OpenAPIFileOption represents OpenAPI options on a file message OpenAPIFileOption { - string file = 1; - grpc.gateway.protoc_gen_openapiv2.options.Swagger option = 2; + string file = 1; + grpc.gateway.protoc_gen_openapiv2.options.Swagger option = 2; } // OpenAPIMethodOption represents OpenAPI options on a method message OpenAPIMethodOption { - string method = 1; - grpc.gateway.protoc_gen_openapiv2.options.Operation option = 2; + string method = 1; + grpc.gateway.protoc_gen_openapiv2.options.Operation option = 2; } // OpenAPIMessageOption represents OpenAPI options on a message message OpenAPIMessageOption { - string message = 1; - grpc.gateway.protoc_gen_openapiv2.options.Schema option = 2; + string message = 1; + grpc.gateway.protoc_gen_openapiv2.options.Schema option = 2; } // OpenAPIServiceOption represents OpenAPI options on a service message OpenAPIServiceOption { - string service = 1; // ex: Service - grpc.gateway.protoc_gen_openapiv2.options.Tag option = 2; + string service = 1; // ex: Service + grpc.gateway.protoc_gen_openapiv2.options.Tag option = 2; } // OpenAPIFieldOption represents OpenAPI options on a field message OpenAPIFieldOption { - string field = 1; - grpc.gateway.protoc_gen_openapiv2.options.JSONSchema option = 2; + string field = 1; + grpc.gateway.protoc_gen_openapiv2.options.JSONSchema option = 2; } // OpenAPIOptions represents OpenAPI protobuf options message OpenAPIOptions { - repeated OpenAPIFileOption file = 1; - repeated OpenAPIMethodOption method = 2; - repeated OpenAPIMessageOption message = 3; - repeated OpenAPIServiceOption service = 4; - repeated OpenAPIFieldOption field = 5; + repeated OpenAPIFileOption file = 1; + repeated OpenAPIMethodOption method = 2; + repeated OpenAPIMessageOption message = 3; + repeated OpenAPIServiceOption service = 4; + repeated OpenAPIFieldOption field = 5; } // OpenAPIConfig represents a set of OpenAPI options message OpenAPIConfig { - OpenAPIOptions openapi_options = 1; + OpenAPIOptions openapi_options = 1; } diff --git a/protoc-gen-openapiv2/options/annotations.proto b/protoc-gen-openapiv2/options/annotations.proto index 1c189e2065c..d63d3c87eb3 100644 --- a/protoc-gen-openapiv2/options/annotations.proto +++ b/protoc-gen-openapiv2/options/annotations.proto @@ -2,11 +2,11 @@ syntax = "proto3"; package grpc.gateway.protoc_gen_openapiv2.options; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; - import "google/protobuf/descriptor.proto"; import "protoc-gen-openapiv2/options/openapiv2.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; + extend google.protobuf.FileOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // diff --git a/protoc-gen-openapiv2/options/openapiv2.proto b/protoc-gen-openapiv2/options/openapiv2.proto index 79d378f3c64..eb8f06e5beb 100644 --- a/protoc-gen-openapiv2/options/openapiv2.proto +++ b/protoc-gen-openapiv2/options/openapiv2.proto @@ -2,10 +2,10 @@ syntax = "proto3"; package grpc.gateway.protoc_gen_openapiv2.options; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; - import "google/protobuf/struct.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; + // Scheme describes the schemes supported by the OpenAPI Swagger // and Operation objects. enum Scheme { diff --git a/runtime/internal/examplepb/example.pb.go b/runtime/internal/examplepb/example.pb.go index 855bcb326ac..bcbe335b902 100644 --- a/runtime/internal/examplepb/example.pb.go +++ b/runtime/internal/examplepb/example.pb.go @@ -1151,14 +1151,14 @@ var file_runtime_internal_examplepb_example_proto_rawDesc = []byte{ 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x70, 0x62, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, + 0x65, 0x70, 0x62, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, 0x0a, 0x0d, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x9b, 0x15, 0x0a, 0x10, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, diff --git a/runtime/internal/examplepb/example.proto b/runtime/internal/examplepb/example.proto index e851fed6380..84886a327cc 100644 --- a/runtime/internal/examplepb/example.proto +++ b/runtime/internal/examplepb/example.proto @@ -1,11 +1,13 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; + package grpc.gateway.runtime.internal.examplepb; +import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; import "google/protobuf/field_mask.proto"; -import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; // SimpleMessage represents a simple message sent to the Echo service. message SimpleMessage { @@ -85,7 +87,9 @@ enum NumericEnum { } message ResponseBodyOut { - message Response { string data = 1; } + message Response { + string data = 1; + } Response response = 2; } @@ -112,22 +116,22 @@ message UpdateMessage { message NestedOuter { NestedOne one = 1; -}; +} message NestedOne { NestedTwo two = 1; -}; +} message NestedTwo { NestedThree three = 1; -}; +} message NestedThree { bool a = 1; bool b = 2; -}; +} message UpdateNestedRequest { NestedOuter nested = 1; google.protobuf.FieldMask update_mask = 2; -}; +} diff --git a/runtime/internal/examplepb/non_standard_names.proto b/runtime/internal/examplepb/non_standard_names.proto index 7c834a55966..d5d6a9099c6 100644 --- a/runtime/internal/examplepb/non_standard_names.proto +++ b/runtime/internal/examplepb/non_standard_names.proto @@ -1,80 +1,82 @@ syntax = "proto3"; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + package grpc.gateway.runtime.internal.examplepb; import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/struct.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; + // NonStandardMessage has oddly named fields. message NonStandardMessage { - // Id represents the message identifier. - string id = 1; - int64 Num = 2; - int64 line_num = 3; - string langIdent = 4; - string STATUS = 5; - int64 en_GB = 6; - string no = 7; + // Id represents the message identifier. + string id = 1; + int64 Num = 2; + int64 line_num = 3; + string langIdent = 4; + string STATUS = 5; + int64 en_GB = 6; + string no = 7; - message Thing { - message SubThing { - string sub_value = 1; - } - SubThing subThing = 1; + message Thing { + message SubThing { + string sub_value = 1; } - Thing thing = 8; - google.protobuf.Struct struct_field = 9; - google.protobuf.Value value_field = 10; + SubThing subThing = 1; + } + Thing thing = 8; + google.protobuf.Struct struct_field = 9; + google.protobuf.Value value_field = 10; } message NonStandardUpdateRequest { - NonStandardMessage body = 1; - google.protobuf.FieldMask update_mask = 2; + NonStandardMessage body = 1; + google.protobuf.FieldMask update_mask = 2; } // NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion. message NonStandardMessageWithJSONNames { - // Id represents the message identifier. - string id = 1 [json_name="ID"]; - int64 Num = 2 [json_name="Num"]; - int64 line_num = 3 [json_name="LineNum"]; - string langIdent = 4 [json_name="langIdent"]; - string STATUS = 5 [json_name="status"]; - int64 en_GB = 6 [json_name="En_GB"]; - string no = 7 [json_name="yes"]; + // Id represents the message identifier. + string id = 1 [json_name = "ID"]; + int64 Num = 2 [json_name = "Num"]; + int64 line_num = 3 [json_name = "LineNum"]; + string langIdent = 4 [json_name = "langIdent"]; + string STATUS = 5 [json_name = "status"]; + int64 en_GB = 6 [json_name = "En_GB"]; + string no = 7 [json_name = "yes"]; - message Thing { - message SubThing { - string sub_value = 1 [json_name="sub_Value"]; - } - SubThing subThing = 1 [json_name="SubThing"]; + message Thing { + message SubThing { + string sub_value = 1 [json_name = "sub_Value"]; } - Thing thing = 8 [json_name="Thingy"]; - google.protobuf.Struct struct_field = 9 [json_name="StructField"]; - google.protobuf.Value value_field = 10 [json_name="ValueField"]; + SubThing subThing = 1 [json_name = "SubThing"]; + } + Thing thing = 8 [json_name = "Thingy"]; + google.protobuf.Struct struct_field = 9 [json_name = "StructField"]; + google.protobuf.Value value_field = 10 [json_name = "ValueField"]; } message NonStandardWithJSONNamesUpdateRequest { - NonStandardMessageWithJSONNames body = 1; - google.protobuf.FieldMask update_mask = 2; + NonStandardMessageWithJSONNames body = 1; + google.protobuf.FieldMask update_mask = 2; } // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. service NonStandardService { - // Apply field mask to empty NonStandardMessage and return result. - rpc Update(NonStandardUpdateRequest) returns (NonStandardMessage) { - option (google.api.http) = { - patch: "/v1/example/non_standard/update" - body: "body" - }; - } + // Apply field mask to empty NonStandardMessage and return result. + rpc Update(NonStandardUpdateRequest) returns (NonStandardMessage) { + option (google.api.http) = { + patch: "/v1/example/non_standard/update" + body: "body" + }; + } - // Apply field mask to empty NonStandardMessageWithJSONNames and return result. - rpc UpdateWithJSONNames(NonStandardWithJSONNamesUpdateRequest) returns (NonStandardMessageWithJSONNames) { - option (google.api.http) = { - patch: "/v1/example/non_standard/update_with_json_names" - body: "body" - }; - } + // Apply field mask to empty NonStandardMessageWithJSONNames and return result. + rpc UpdateWithJSONNames(NonStandardWithJSONNamesUpdateRequest) returns (NonStandardMessageWithJSONNames) { + option (google.api.http) = { + patch: "/v1/example/non_standard/update_with_json_names" + body: "body" + }; + } } diff --git a/runtime/internal/examplepb/proto3.pb.go b/runtime/internal/examplepb/proto3.pb.go index e8abcc1b4eb..a6071398d4c 100644 --- a/runtime/internal/examplepb/proto3.pb.go +++ b/runtime/internal/examplepb/proto3.pb.go @@ -530,12 +530,12 @@ var file_runtime_internal_examplepb_proto3_proto_rawDesc = []byte{ 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xce, 0x21, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4e, 0x0a, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x29, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, diff --git a/runtime/internal/examplepb/proto3.proto b/runtime/internal/examplepb/proto3.proto index 93ffc1256a6..7e492d391fa 100644 --- a/runtime/internal/examplepb/proto3.proto +++ b/runtime/internal/examplepb/proto3.proto @@ -2,13 +2,13 @@ syntax = "proto3"; package grpc.gateway.runtime.internal.examplepb; -option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; - import "google/protobuf/duration.proto"; import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; -import "google/protobuf/struct.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; message Proto3Message { // Next number: 49