From 2cb2dfbd4c72b13c88abc7828f9b276bf7e66133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Br=C3=BCderl?= Date: Thu, 8 Nov 2018 16:51:33 +0100 Subject: [PATCH] Swagger-gen: Major overhaul of well-known-type handling - swaggerSchemaObject.Properties is now optional (pointer), because google.protobuf.Empty requires us to set Properties{} instead of nil, because this equals in Swagger to an empty JSON object (which is exactly what Empty represents and how the gateway treats it). If it's not a pointer, we can't distinguish between "not set" (in most cases, we don't want Properties to be set, instead usually just .Ref is set), and "set to an empty value e.g. Properties{} with length 0). We don't want Properties{} to occur except for specific cases, e.g. for Empty. - Wrappers and Empty are not rendered as definitions, now also for RPC Method input/output. instead, all necessary schema information is provided "in-line" via schema.type and schema.properties. - Empty is now omitted as well if it's input/output of a RPC Method. --- Makefile | 1 - examples/clients/abe/BUILD.bazel | 1 - .../abe/a_bit_of_everything_service_api.go | 60 +-- .../abe/camel_case_service_name_api.go | 6 +- .../abe/examplepb_a_bit_of_everything.go | 2 +- examples/clients/abe/protobuf_empty.go | 15 - .../a_bit_of_everything.swagger.json | 29 +- examples/proto/examplepb/wrappers.pb.go | 404 +++++++++++++++-- examples/proto/examplepb/wrappers.pb.gw.go | 412 ++++++++++++++++++ examples/proto/examplepb/wrappers.proto | 62 +++ .../proto/examplepb/wrappers.swagger.json | 276 ++++++++++++ protoc-gen-swagger/genswagger/template.go | 92 ++-- protoc-gen-swagger/genswagger/types.go | 4 +- 13 files changed, 1232 insertions(+), 132 deletions(-) delete mode 100644 examples/clients/abe/protobuf_empty.go diff --git a/Makefile b/Makefile index d7eb8fa9781..b2d6722d2c7 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,6 @@ ABE_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/abe/a_bit_of_everything_nested.go \ $(EXAMPLE_CLIENT_DIR)/abe/examplepb_body.go \ $(EXAMPLE_CLIENT_DIR)/abe/examplepb_numeric_enum.go \ $(EXAMPLE_CLIENT_DIR)/abe/nested_deep_enum.go \ - $(EXAMPLE_CLIENT_DIR)/abe/protobuf_empty.go \ $(EXAMPLE_CLIENT_DIR)/abe/sub_string_message.go UNANNOTATED_ECHO_EXAMPLE_SPEC=examples/proto/examplepb/unannotated_echo_service.swagger.json UNANNOTATED_ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/unannotatedecho/api_client.go \ diff --git a/examples/clients/abe/BUILD.bazel b/examples/clients/abe/BUILD.bazel index 5df684b7f31..4d3c3546e93 100644 --- a/examples/clients/abe/BUILD.bazel +++ b/examples/clients/abe/BUILD.bazel @@ -22,7 +22,6 @@ go_library( "message_path_enum_nested_path_enum.go", "nested_deep_enum.go", "pathenum_path_enum.go", - "protobuf_empty.go", "protobuf_field_mask.go", "sub_string_message.go", ], diff --git a/examples/clients/abe/a_bit_of_everything_service_api.go b/examples/clients/abe/a_bit_of_everything_service_api.go index 5e8d72779c3..85e864ca833 100644 --- a/examples/clients/abe/a_bit_of_everything_service_api.go +++ b/examples/clients/abe/a_bit_of_everything_service_api.go @@ -303,9 +303,9 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E * * * @param uuid - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Delete(uuid string) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables @@ -350,7 +350,7 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -371,9 +371,9 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes /** * * - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -422,7 +422,7 @@ func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*ProtobufEmpty, *APIResp if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -445,9 +445,9 @@ func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*ProtobufEmpty, *APIResp * * @param id * @param body - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -499,7 +499,7 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -547,9 +547,9 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb * @param nonConventionalNameValue * @param timestampValue * @param repeatedEnumValue repeated enum value. it is comma-separated in query. - ZERO: ZERO means 0 - ONE: ONE means 1 - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName string, singleNestedAmount int64, singleNestedOk string, floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName string, singleNestedAmount int64, singleNestedOk string, floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -616,7 +616,7 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -817,9 +817,9 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth * * @param abeUuid * @param body - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, body ExamplepbUpdateV2Request) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, body ExamplepbUpdateV2Request) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Patch") // create path and map variables @@ -871,7 +871,7 @@ func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, bod } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -894,9 +894,9 @@ func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, bod * * @param name * @param body - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -948,7 +948,7 @@ func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body Examplep } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -969,9 +969,9 @@ func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body Examplep /** * * - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Timeout() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -1020,7 +1020,7 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -1043,9 +1043,9 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err * * @param uuid * @param body - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables @@ -1097,7 +1097,7 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -1120,9 +1120,9 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver * * @param abeUuid * @param body - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitOfEverything) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables @@ -1174,7 +1174,7 @@ func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitO } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) @@ -1197,9 +1197,9 @@ func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitO * * @param abeUuid * @param body - * @return *ProtobufEmpty + * @return *interface{} */ -func (a ABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABitOfEverything) (*ProtobufEmpty, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Patch") // create path and map variables @@ -1251,7 +1251,7 @@ func (a ABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABit } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) diff --git a/examples/clients/abe/camel_case_service_name_api.go b/examples/clients/abe/camel_case_service_name_api.go index ff49b76851b..cb8cb48fd99 100644 --- a/examples/clients/abe/camel_case_service_name_api.go +++ b/examples/clients/abe/camel_case_service_name_api.go @@ -40,9 +40,9 @@ func NewCamelCaseServiceNameApiWithBasePath(basePath string) *CamelCaseServiceNa * Create a new ABitOfEverything * This API creates a new ABitOfEverything * - * @return *ProtobufEmpty + * @return *interface{} */ -func (a CamelCaseServiceNameApi) Empty() (*ProtobufEmpty, *APIResponse, error) { +func (a CamelCaseServiceNameApi) Empty() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -91,7 +91,7 @@ func (a CamelCaseServiceNameApi) Empty() (*ProtobufEmpty, *APIResponse, error) { if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) + var successPayload = new(interface{}) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) diff --git a/examples/clients/abe/examplepb_a_bit_of_everything.go b/examples/clients/abe/examplepb_a_bit_of_everything.go index f413637e1ca..9701914d126 100644 --- a/examples/clients/abe/examplepb_a_bit_of_everything.go +++ b/examples/clients/abe/examplepb_a_bit_of_everything.go @@ -61,7 +61,7 @@ type ExamplepbABitOfEverything struct { RepeatedStringValue []string `json:"repeated_string_value,omitempty"` - OneofEmpty ProtobufEmpty `json:"oneof_empty,omitempty"` + OneofEmpty interface{} `json:"oneof_empty,omitempty"` OneofString string `json:"oneof_string,omitempty"` diff --git a/examples/clients/abe/protobuf_empty.go b/examples/clients/abe/protobuf_empty.go deleted file mode 100644 index 97c7bf612b8..00000000000 --- a/examples/clients/abe/protobuf_empty.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * A Bit of Everything - * - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 1.0 - * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git - */ - -package abe - -// service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON object `{}`. -type ProtobufEmpty struct { -} diff --git a/examples/proto/examplepb/a_bit_of_everything.swagger.json b/examples/proto/examplepb/a_bit_of_everything.swagger.json index b3249e62612..227bb4eeea5 100644 --- a/examples/proto/examplepb/a_bit_of_everything.swagger.json +++ b/examples/proto/examplepb/a_bit_of_everything.swagger.json @@ -128,7 +128,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -636,7 +636,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -683,7 +683,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -960,7 +960,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1006,7 +1006,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1160,7 +1160,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1192,7 +1192,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1224,7 +1224,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1272,7 +1272,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1304,7 +1304,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1352,7 +1352,7 @@ "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} } }, "403": { @@ -1521,7 +1521,7 @@ } }, "oneof_empty": { - "$ref": "#/definitions/protobufEmpty" + "properties": {} }, "oneof_string": { "type": "string" @@ -1723,11 +1723,6 @@ ], "default": "ABC" }, - "protobufEmpty": { - "type": "object", - "description": "service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\nThe JSON representation for `Empty` is empty JSON object `{}`.", - "title": "A generic empty message that you can re-use to avoid defining duplicated\nempty messages in your APIs. A typical example is to use it as the request\nor the response type of an API method. For instance:" - }, "protobufFieldMask": { "type": "object", "properties": { diff --git a/examples/proto/examplepb/wrappers.pb.go b/examples/proto/examplepb/wrappers.pb.go index fb44ca7aba9..0b0616ee60c 100644 --- a/examples/proto/examplepb/wrappers.pb.go +++ b/examples/proto/examplepb/wrappers.pb.go @@ -6,6 +6,7 @@ package examplepb import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" +import empty "github.com/golang/protobuf/ptypes/empty" import wrappers "github.com/golang/protobuf/ptypes/wrappers" import _ "google.golang.org/genproto/googleapis/api/annotations" @@ -44,7 +45,7 @@ func (m *Wrappers) Reset() { *m = Wrappers{} } func (m *Wrappers) String() string { return proto.CompactTextString(m) } func (*Wrappers) ProtoMessage() {} func (*Wrappers) Descriptor() ([]byte, []int) { - return fileDescriptor_wrappers_5850bd48b0187754, []int{0} + return fileDescriptor_wrappers_3d2e9c7780d635b4, []int{0} } func (m *Wrappers) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Wrappers.Unmarshal(m, b) @@ -144,6 +145,16 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type WrappersServiceClient interface { Create(ctx context.Context, in *Wrappers, opts ...grpc.CallOption) (*Wrappers, error) + CreateStringValue(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*wrappers.StringValue, error) + CreateInt32Value(ctx context.Context, in *wrappers.Int32Value, opts ...grpc.CallOption) (*wrappers.Int32Value, error) + CreateInt64Value(ctx context.Context, in *wrappers.Int64Value, opts ...grpc.CallOption) (*wrappers.Int64Value, error) + CreateFloatValue(ctx context.Context, in *wrappers.FloatValue, opts ...grpc.CallOption) (*wrappers.FloatValue, error) + CreateDoubleValue(ctx context.Context, in *wrappers.DoubleValue, opts ...grpc.CallOption) (*wrappers.DoubleValue, error) + CreateBoolValue(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*wrappers.BoolValue, error) + CreateUInt32Value(ctx context.Context, in *wrappers.UInt32Value, opts ...grpc.CallOption) (*wrappers.UInt32Value, error) + CreateUInt64Value(ctx context.Context, in *wrappers.UInt64Value, opts ...grpc.CallOption) (*wrappers.UInt64Value, error) + CreateBytesValue(ctx context.Context, in *wrappers.BytesValue, opts ...grpc.CallOption) (*wrappers.BytesValue, error) + CreateEmpty(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) } type wrappersServiceClient struct { @@ -163,9 +174,109 @@ func (c *wrappersServiceClient) Create(ctx context.Context, in *Wrappers, opts . return out, nil } +func (c *wrappersServiceClient) CreateStringValue(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*wrappers.StringValue, error) { + out := new(wrappers.StringValue) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateStringValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateInt32Value(ctx context.Context, in *wrappers.Int32Value, opts ...grpc.CallOption) (*wrappers.Int32Value, error) { + out := new(wrappers.Int32Value) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateInt32Value", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateInt64Value(ctx context.Context, in *wrappers.Int64Value, opts ...grpc.CallOption) (*wrappers.Int64Value, error) { + out := new(wrappers.Int64Value) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateInt64Value", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateFloatValue(ctx context.Context, in *wrappers.FloatValue, opts ...grpc.CallOption) (*wrappers.FloatValue, error) { + out := new(wrappers.FloatValue) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateFloatValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateDoubleValue(ctx context.Context, in *wrappers.DoubleValue, opts ...grpc.CallOption) (*wrappers.DoubleValue, error) { + out := new(wrappers.DoubleValue) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateDoubleValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateBoolValue(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*wrappers.BoolValue, error) { + out := new(wrappers.BoolValue) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateBoolValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateUInt32Value(ctx context.Context, in *wrappers.UInt32Value, opts ...grpc.CallOption) (*wrappers.UInt32Value, error) { + out := new(wrappers.UInt32Value) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateUInt32Value", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateUInt64Value(ctx context.Context, in *wrappers.UInt64Value, opts ...grpc.CallOption) (*wrappers.UInt64Value, error) { + out := new(wrappers.UInt64Value) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateUInt64Value", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateBytesValue(ctx context.Context, in *wrappers.BytesValue, opts ...grpc.CallOption) (*wrappers.BytesValue, error) { + out := new(wrappers.BytesValue) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateBytesValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *wrappersServiceClient) CreateEmpty(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/grpc.gateway.examples.examplepb.WrappersService/CreateEmpty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // WrappersServiceServer is the server API for WrappersService service. type WrappersServiceServer interface { Create(context.Context, *Wrappers) (*Wrappers, error) + CreateStringValue(context.Context, *wrappers.StringValue) (*wrappers.StringValue, error) + CreateInt32Value(context.Context, *wrappers.Int32Value) (*wrappers.Int32Value, error) + CreateInt64Value(context.Context, *wrappers.Int64Value) (*wrappers.Int64Value, error) + CreateFloatValue(context.Context, *wrappers.FloatValue) (*wrappers.FloatValue, error) + CreateDoubleValue(context.Context, *wrappers.DoubleValue) (*wrappers.DoubleValue, error) + CreateBoolValue(context.Context, *wrappers.BoolValue) (*wrappers.BoolValue, error) + CreateUInt32Value(context.Context, *wrappers.UInt32Value) (*wrappers.UInt32Value, error) + CreateUInt64Value(context.Context, *wrappers.UInt64Value) (*wrappers.UInt64Value, error) + CreateBytesValue(context.Context, *wrappers.BytesValue) (*wrappers.BytesValue, error) + CreateEmpty(context.Context, *empty.Empty) (*empty.Empty, error) } func RegisterWrappersServiceServer(s *grpc.Server, srv WrappersServiceServer) { @@ -190,6 +301,186 @@ func _WrappersService_Create_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _WrappersService_CreateStringValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateStringValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateStringValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateStringValue(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateInt32Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.Int32Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateInt32Value(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateInt32Value", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateInt32Value(ctx, req.(*wrappers.Int32Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateInt64Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.Int64Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateInt64Value(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateInt64Value", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateInt64Value(ctx, req.(*wrappers.Int64Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateFloatValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.FloatValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateFloatValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateFloatValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateFloatValue(ctx, req.(*wrappers.FloatValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateDoubleValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.DoubleValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateDoubleValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateDoubleValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateDoubleValue(ctx, req.(*wrappers.DoubleValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateBoolValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.BoolValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateBoolValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateBoolValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateBoolValue(ctx, req.(*wrappers.BoolValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateUInt32Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.UInt32Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateUInt32Value(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateUInt32Value", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateUInt32Value(ctx, req.(*wrappers.UInt32Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateUInt64Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.UInt64Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateUInt64Value(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateUInt64Value", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateUInt64Value(ctx, req.(*wrappers.UInt64Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateBytesValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.BytesValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateBytesValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateBytesValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateBytesValue(ctx, req.(*wrappers.BytesValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _WrappersService_CreateEmpty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WrappersServiceServer).CreateEmpty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.gateway.examples.examplepb.WrappersService/CreateEmpty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WrappersServiceServer).CreateEmpty(ctx, req.(*empty.Empty)) + } + return interceptor(ctx, in, info, handler) +} + var _WrappersService_serviceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.examplepb.WrappersService", HandlerType: (*WrappersServiceServer)(nil), @@ -198,39 +489,92 @@ var _WrappersService_serviceDesc = grpc.ServiceDesc{ MethodName: "Create", Handler: _WrappersService_Create_Handler, }, + { + MethodName: "CreateStringValue", + Handler: _WrappersService_CreateStringValue_Handler, + }, + { + MethodName: "CreateInt32Value", + Handler: _WrappersService_CreateInt32Value_Handler, + }, + { + MethodName: "CreateInt64Value", + Handler: _WrappersService_CreateInt64Value_Handler, + }, + { + MethodName: "CreateFloatValue", + Handler: _WrappersService_CreateFloatValue_Handler, + }, + { + MethodName: "CreateDoubleValue", + Handler: _WrappersService_CreateDoubleValue_Handler, + }, + { + MethodName: "CreateBoolValue", + Handler: _WrappersService_CreateBoolValue_Handler, + }, + { + MethodName: "CreateUInt32Value", + Handler: _WrappersService_CreateUInt32Value_Handler, + }, + { + MethodName: "CreateUInt64Value", + Handler: _WrappersService_CreateUInt64Value_Handler, + }, + { + MethodName: "CreateBytesValue", + Handler: _WrappersService_CreateBytesValue_Handler, + }, + { + MethodName: "CreateEmpty", + Handler: _WrappersService_CreateEmpty_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/proto/examplepb/wrappers.proto", } func init() { - proto.RegisterFile("examples/proto/examplepb/wrappers.proto", fileDescriptor_wrappers_5850bd48b0187754) -} - -var fileDescriptor_wrappers_5850bd48b0187754 = []byte{ - // 381 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xdf, 0x4a, 0xf3, 0x30, - 0x18, 0xc6, 0xe9, 0xbe, 0x7d, 0x73, 0x4b, 0x05, 0xa1, 0x78, 0xa0, 0x75, 0x38, 0xd9, 0x89, 0x7f, - 0x0e, 0x52, 0xdc, 0xc6, 0x40, 0x11, 0x84, 0x29, 0x82, 0xa7, 0x0e, 0x15, 0x3c, 0x91, 0x64, 0xcb, - 0x4a, 0xa1, 0x36, 0x25, 0x4d, 0x37, 0x77, 0x24, 0x78, 0x09, 0x7a, 0x45, 0x5e, 0x83, 0xb7, 0xe0, - 0x85, 0x48, 0xb2, 0x37, 0xd9, 0x74, 0x54, 0x3d, 0x7b, 0xde, 0xe6, 0xf9, 0x3d, 0xe1, 0x7d, 0x48, - 0xd1, 0x2e, 0x7b, 0x24, 0x0f, 0x69, 0xcc, 0xb2, 0x20, 0x15, 0x5c, 0xf2, 0x00, 0xc6, 0x94, 0x06, - 0x13, 0x41, 0xd2, 0x94, 0x89, 0x0c, 0xeb, 0x03, 0xaf, 0x11, 0x8a, 0x74, 0x80, 0x43, 0x22, 0xd9, - 0x84, 0x4c, 0xb1, 0xa1, 0xb0, 0xf5, 0xfb, 0xf5, 0x90, 0xf3, 0x30, 0x66, 0x01, 0x49, 0xa3, 0x80, - 0x24, 0x09, 0x97, 0x44, 0x46, 0x3c, 0x01, 0xdc, 0xdf, 0x86, 0x53, 0x3d, 0xd1, 0x7c, 0xf4, 0x2d, - 0xbe, 0xf9, 0x56, 0x46, 0xd5, 0x5b, 0xf8, 0xe4, 0x9d, 0xa2, 0xd5, 0x4c, 0x8a, 0x28, 0x09, 0xef, - 0xc7, 0x24, 0xce, 0xd9, 0x86, 0xb3, 0xe3, 0xec, 0xb9, 0xad, 0x3a, 0x9e, 0x65, 0x60, 0x93, 0x81, - 0xfb, 0xda, 0x74, 0xa3, 0x3c, 0x57, 0x6e, 0x36, 0x1f, 0xbc, 0x13, 0xe4, 0x46, 0x89, 0x6c, 0xb7, - 0x80, 0x2f, 0x69, 0x7e, 0x6b, 0x89, 0xbf, 0x54, 0x9e, 0x19, 0x8e, 0x22, 0xab, 0x81, 0xee, 0x76, - 0x80, 0xfe, 0x57, 0x4c, 0x77, 0x3b, 0x73, 0x1a, 0xb4, 0xa2, 0x47, 0x31, 0x27, 0x12, 0xe8, 0x72, - 0x01, 0x7d, 0xa1, 0x3c, 0x40, 0x8f, 0xac, 0x56, 0xab, 0x0f, 0x79, 0x4e, 0x63, 0x06, 0xf8, 0xff, - 0x82, 0xd5, 0xcf, 0xb5, 0x09, 0x56, 0x1f, 0xce, 0x07, 0xef, 0x08, 0x21, 0xca, 0x79, 0x0c, 0x78, - 0x45, 0xe3, 0xfe, 0x12, 0xde, 0xe3, 0x3c, 0x9e, 0xc1, 0x35, 0x6a, 0xa4, 0xba, 0x3b, 0x5f, 0xac, - 0x6d, 0xa5, 0xe0, 0xee, 0xeb, 0x85, 0xde, 0xdc, 0x7c, 0xa1, 0x38, 0x08, 0xb0, 0xcd, 0x55, 0x7f, - 0x08, 0x30, 0xd5, 0xb9, 0xf9, 0xd7, 0xee, 0xe8, 0x54, 0xb2, 0x0c, 0xf8, 0x5a, 0x41, 0x77, 0x3d, - 0xe5, 0x81, 0xee, 0xa8, 0xd5, 0xad, 0x17, 0x07, 0xad, 0x99, 0x37, 0xd4, 0x67, 0x62, 0x1c, 0x0d, - 0x98, 0xf7, 0x84, 0x2a, 0x67, 0x82, 0x11, 0xc9, 0xbc, 0x7d, 0xfc, 0xcb, 0x0b, 0xc6, 0x86, 0xf5, - 0xff, 0x6e, 0x6d, 0x36, 0x9e, 0xdf, 0x3f, 0x5e, 0x4b, 0x9b, 0xcd, 0xf5, 0x60, 0x7c, 0x68, 0x7e, - 0x1e, 0xfb, 0xb6, 0x8f, 0x9d, 0x83, 0x9e, 0x7b, 0x57, 0xb3, 0x18, 0xad, 0xe8, 0x15, 0xda, 0x9f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xc7, 0xe3, 0xe9, 0x76, 0x03, 0x00, 0x00, + proto.RegisterFile("examples/proto/examplepb/wrappers.proto", fileDescriptor_wrappers_3d2e9c7780d635b4) +} + +var fileDescriptor_wrappers_3d2e9c7780d635b4 = []byte{ + // 578 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x95, 0xdd, 0x6e, 0xd3, 0x30, + 0x14, 0xc7, 0xd5, 0x31, 0xca, 0xea, 0x0c, 0xc6, 0x0c, 0x82, 0xcd, 0x9b, 0x18, 0xca, 0x0d, 0xb0, + 0x8b, 0x44, 0x74, 0x55, 0x25, 0x26, 0x24, 0xa4, 0xf2, 0x21, 0x71, 0xcb, 0x34, 0x26, 0x71, 0x83, + 0xec, 0xcd, 0x8d, 0x82, 0xb2, 0x38, 0x4a, 0x9c, 0x8e, 0x5e, 0x21, 0xf1, 0x0a, 0x3c, 0x00, 0xcf, + 0xc2, 0x33, 0xf0, 0x0a, 0x3c, 0x08, 0xf2, 0x57, 0x3e, 0x9a, 0xe5, 0xc0, 0x9d, 0x9d, 0xff, 0xf9, + 0x9d, 0x7f, 0x7d, 0x7c, 0x8e, 0x8b, 0x9e, 0xf0, 0xaf, 0xf4, 0x32, 0x4b, 0x78, 0x11, 0x66, 0xb9, + 0x90, 0x22, 0xb4, 0xdb, 0x8c, 0x85, 0x57, 0x39, 0xcd, 0x32, 0x9e, 0x17, 0x81, 0x16, 0xf0, 0x41, + 0x94, 0x67, 0xe7, 0x41, 0x44, 0x25, 0xbf, 0xa2, 0xcb, 0xc0, 0x51, 0x41, 0x15, 0x4f, 0xf6, 0x23, + 0x21, 0xa2, 0x84, 0x87, 0x34, 0x8b, 0x43, 0x9a, 0xa6, 0x42, 0x52, 0x19, 0x8b, 0xd4, 0xe2, 0xe4, + 0x91, 0x55, 0xf5, 0x8e, 0x95, 0xf3, 0x95, 0xf4, 0x64, 0x6f, 0x55, 0xe7, 0x97, 0x99, 0x5c, 0x1a, + 0xd1, 0xff, 0xb5, 0x8e, 0x36, 0xce, 0x6c, 0x3c, 0x7e, 0x85, 0x36, 0x0b, 0x99, 0xc7, 0x69, 0xf4, + 0x79, 0x41, 0x93, 0x92, 0xef, 0x0c, 0x1e, 0x0f, 0x9e, 0x7a, 0xe3, 0xfd, 0xc0, 0x24, 0x08, 0x5c, + 0x82, 0xe0, 0x44, 0x07, 0x7d, 0x54, 0x31, 0x1f, 0xbc, 0xa2, 0xde, 0xe0, 0x97, 0xc8, 0x8b, 0x53, + 0x79, 0x34, 0xb6, 0xfc, 0x9a, 0xe6, 0xf7, 0x3a, 0xfc, 0x7b, 0x15, 0x63, 0x70, 0x14, 0x57, 0x6b, + 0x4b, 0x4f, 0x27, 0x96, 0xbe, 0xd1, 0x4f, 0x4f, 0x27, 0x35, 0x6d, 0xd7, 0x8a, 0x9e, 0x27, 0x82, + 0x4a, 0x4b, 0xaf, 0xf7, 0xd0, 0xef, 0x54, 0x8c, 0xa5, 0xe7, 0xd5, 0x5a, 0x1d, 0xfd, 0x42, 0x94, + 0x2c, 0xe1, 0x16, 0xbf, 0xd9, 0x73, 0xf4, 0x37, 0x3a, 0xc8, 0x1e, 0xfd, 0xa2, 0xde, 0xe0, 0x17, + 0x08, 0x31, 0x21, 0x12, 0x8b, 0x0f, 0x35, 0x4e, 0x3a, 0xf8, 0x4c, 0x88, 0xc4, 0xc0, 0x23, 0xe6, + 0x96, 0xca, 0xbb, 0x6c, 0x96, 0xed, 0x56, 0x8f, 0xf7, 0x69, 0xa3, 0x6e, 0x5e, 0xd9, 0x28, 0x9c, + 0x4d, 0x50, 0x55, 0x6e, 0x03, 0x48, 0xe0, 0x4a, 0xe7, 0x95, 0xed, 0xda, 0xb1, 0xa5, 0xe4, 0x85, + 0xe5, 0x47, 0x3d, 0xb5, 0x9b, 0xa9, 0x18, 0x5b, 0x3b, 0x56, 0xad, 0xc7, 0x3f, 0x47, 0x68, 0xcb, + 0xf5, 0xd0, 0x09, 0xcf, 0x17, 0xf1, 0x39, 0xc7, 0xdf, 0xd0, 0xf0, 0x75, 0xce, 0xa9, 0xe4, 0xf8, + 0x59, 0xf0, 0x8f, 0xf6, 0x0e, 0x1c, 0x4b, 0xfe, 0x3f, 0xd4, 0x3f, 0xf8, 0xfe, 0xfb, 0xcf, 0x8f, + 0xb5, 0x5d, 0xff, 0x7e, 0xb8, 0x78, 0xee, 0x26, 0xab, 0x6a, 0xfc, 0xe3, 0xc1, 0x21, 0xfe, 0x82, + 0xb6, 0xcd, 0x0f, 0x68, 0x34, 0x2b, 0x06, 0x5b, 0x99, 0x80, 0xaa, 0xbf, 0xab, 0x1d, 0xef, 0xf9, + 0x77, 0x94, 0xa3, 0xe4, 0x85, 0x34, 0xa2, 0xf2, 0x9a, 0xa3, 0xbb, 0xc6, 0xab, 0xbe, 0x20, 0x0c, + 0x75, 0x3d, 0x81, 0x44, 0x7f, 0x47, 0x1b, 0x61, 0xff, 0xb6, 0x33, 0xd2, 0xda, 0xaa, 0x8f, 0xbb, + 0x3a, 0x68, 0x3e, 0x08, 0x24, 0x5e, 0xeb, 0x33, 0x9d, 0xb4, 0x7c, 0xea, 0x61, 0xc1, 0xd0, 0x24, + 0x11, 0x48, 0xec, 0xfa, 0x68, 0xad, 0x75, 0x47, 0x8d, 0xa9, 0xc2, 0xe0, 0xcc, 0x11, 0x50, 0xed, + 0xde, 0x91, 0x11, 0x95, 0x17, 0x43, 0x5b, 0xc6, 0xab, 0x1a, 0x41, 0x0c, 0x8c, 0x27, 0x01, 0x34, + 0xff, 0xa1, 0x76, 0xd9, 0xf6, 0x37, 0x9d, 0x8b, 0x92, 0x5a, 0xe7, 0x69, 0x4c, 0x2a, 0x06, 0xe7, + 0x98, 0x80, 0x6a, 0xf7, 0x3c, 0xa7, 0xb1, 0xeb, 0x85, 0x96, 0x97, 0x6b, 0x06, 0x70, 0xe4, 0x09, + 0xa8, 0x5e, 0xef, 0xb5, 0xd2, 0x0f, 0xf5, 0x03, 0x80, 0xa1, 0xd7, 0x81, 0x40, 0x62, 0xb7, 0x1f, + 0xb4, 0xa6, 0x7c, 0xce, 0x90, 0x67, 0x7c, 0xde, 0xaa, 0x7f, 0x28, 0xfc, 0xa0, 0x93, 0x45, 0x7f, + 0x27, 0x3d, 0xdf, 0xbb, 0x89, 0xf5, 0xe7, 0xe3, 0xc1, 0xe1, 0xcc, 0xfb, 0x34, 0xaa, 0xde, 0x10, + 0x36, 0xd4, 0xd8, 0xd1, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x05, 0x83, 0xaf, 0x71, 0xa0, 0x07, + 0x00, 0x00, } diff --git a/examples/proto/examplepb/wrappers.pb.gw.go b/examples/proto/examplepb/wrappers.pb.gw.go index 7e95a4c6163..703f2e604fb 100644 --- a/examples/proto/examplepb/wrappers.pb.gw.go +++ b/examples/proto/examplepb/wrappers.pb.gw.go @@ -13,6 +13,8 @@ import ( "net/http" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/empty" + "github.com/golang/protobuf/ptypes/wrappers" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/utilities" "golang.org/x/net/context" @@ -45,6 +47,176 @@ func request_WrappersService_Create_0(ctx context.Context, marshaler runtime.Mar } +func request_WrappersService_CreateStringValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.StringValue + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateStringValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateInt32Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.Int32Value + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateInt32Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateInt64Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.Int64Value + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateInt64Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateFloatValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.FloatValue + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateFloatValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateDoubleValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.DoubleValue + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateDoubleValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateBoolValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.BoolValue + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateBoolValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateUInt32Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.UInt32Value + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateUInt32Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateUInt64Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.UInt64Value + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateUInt64Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateBytesValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq wrappers.BytesValue + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateBytesValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_WrappersService_CreateEmpty_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq empty.Empty + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateEmpty(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + // RegisterWrappersServiceHandlerFromEndpoint is same as RegisterWrappersServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterWrappersServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { @@ -103,13 +275,253 @@ func RegisterWrappersServiceHandlerClient(ctx context.Context, mux *runtime.Serv }) + mux.Handle("POST", pattern_WrappersService_CreateStringValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateStringValue_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateStringValue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateInt32Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateInt32Value_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateInt32Value_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateInt64Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateInt64Value_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateInt64Value_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateFloatValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateFloatValue_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateFloatValue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateDoubleValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateDoubleValue_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateDoubleValue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateBoolValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateBoolValue_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateBoolValue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateUInt32Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateUInt32Value_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateUInt32Value_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateUInt64Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateUInt64Value_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateUInt64Value_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateBytesValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateBytesValue_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateBytesValue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_WrappersService_CreateEmpty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_WrappersService_CreateEmpty_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_WrappersService_CreateEmpty_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_WrappersService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "wrappers"}, "")) + + pattern_WrappersService_CreateStringValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testString"}, "")) + + pattern_WrappersService_CreateInt32Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testInt32"}, "")) + + pattern_WrappersService_CreateInt64Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testInt64"}, "")) + + pattern_WrappersService_CreateFloatValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testFloat"}, "")) + + pattern_WrappersService_CreateDoubleValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testDouble"}, "")) + + pattern_WrappersService_CreateBoolValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testBool"}, "")) + + pattern_WrappersService_CreateUInt32Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testUint32"}, "")) + + pattern_WrappersService_CreateUInt64Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testUint64"}, "")) + + pattern_WrappersService_CreateBytesValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testBytes"}, "")) + + pattern_WrappersService_CreateEmpty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testEmpty"}, "")) ) var ( forward_WrappersService_Create_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateStringValue_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateInt32Value_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateInt64Value_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateFloatValue_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateDoubleValue_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateBoolValue_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateUInt32Value_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateUInt64Value_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateBytesValue_0 = runtime.ForwardResponseMessage + + forward_WrappersService_CreateEmpty_0 = runtime.ForwardResponseMessage ) diff --git a/examples/proto/examplepb/wrappers.proto b/examples/proto/examplepb/wrappers.proto index b232a37fc83..46b2552a3f7 100644 --- a/examples/proto/examplepb/wrappers.proto +++ b/examples/proto/examplepb/wrappers.proto @@ -4,6 +4,7 @@ package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; import "google/protobuf/wrappers.proto"; +import "google/protobuf/empty.proto"; message Wrappers { google.protobuf.StringValue string_value = 1; @@ -24,4 +25,65 @@ service WrappersService { 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/proto/examplepb/wrappers.swagger.json b/examples/proto/examplepb/wrappers.swagger.json index 8e2df83bb20..f45b512e1c6 100644 --- a/examples/proto/examplepb/wrappers.swagger.json +++ b/examples/proto/examplepb/wrappers.swagger.json @@ -40,6 +40,282 @@ "WrappersService" ] } + }, + "/v1/testBool": { + "post": { + "operationId": "CreateBoolValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "boolean", + "format": "boolean" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "boolean", + "format": "boolean" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testBytes": { + "post": { + "operationId": "CreateBytesValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "string", + "format": "byte" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "byte" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testDouble": { + "post": { + "operationId": "CreateDoubleValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "number", + "format": "double" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "number", + "format": "double" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testEmpty": { + "post": { + "operationId": "CreateEmpty", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "properties": {} + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "properties": {} + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testFloat": { + "post": { + "operationId": "CreateFloatValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "number", + "format": "float" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "number", + "format": "float" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testInt32": { + "post": { + "operationId": "CreateInt32Value", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "integer", + "format": "int32" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testInt64": { + "post": { + "operationId": "CreateInt64Value", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "string", + "format": "int64" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "int64" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testString": { + "post": { + "operationId": "CreateStringValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "string" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testUint32": { + "post": { + "operationId": "CreateUInt32Value", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "integer", + "format": "int64" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "tags": [ + "WrappersService" + ] + } + }, + "/v1/testUint64": { + "post": { + "operationId": "CreateUInt64Value", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "string", + "format": "uint64" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "uint64" + } + } + ], + "tags": [ + "WrappersService" + ] + } } }, "definitions": { diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index f2f9a8e354a..930b6c78d7d 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -58,6 +58,7 @@ var wktSchemas = map[string]schemaCore{ Type: "boolean", Format: "boolean", }, + ".google.protobuf.Empty": schemaCore{}, } func listEnumNames(enum *descriptor.Enum) (names []string) { @@ -170,11 +171,15 @@ func findServicesMessagesAndEnumerations(s []*descriptor.Service, reg *descripto for _, meth := range svc.Methods { // Request may be fully included in query if _, ok := refs[fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg))]; ok { - m[fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg)] = meth.RequestType + if !skipRenderingRef(meth.RequestType.FQMN()) { + m[fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg)] = meth.RequestType + } } findNestedMessagesAndEnumerations(meth.RequestType, reg, m, e) - m[fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg)] = meth.ResponseType + if !skipRenderingRef(meth.ResponseType.FQMN()) { + m[fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg)] = meth.ResponseType + } findNestedMessagesAndEnumerations(meth.ResponseType, reg, m, e) } } @@ -204,32 +209,19 @@ func findNestedMessagesAndEnumerations(message *descriptor.Message, reg *descrip } } +func skipRenderingRef(refName string) bool { + if _, ok := wktSchemas[refName]; ok { + return true + } + return false +} + func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, reg *descriptor.Registry, customRefs refMap) { for name, msg := range messages { - switch name { - case ".google.protobuf.Timestamp": - continue - case ".google.protobuf.Duration": - continue - case ".google.protobuf.StringValue": - continue - case ".google.protobuf.BytesValue": - continue - case ".google.protobuf.Int32Value": - continue - case ".google.protobuf.UInt32Value": - continue - case ".google.protobuf.Int64Value": - continue - case ".google.protobuf.UInt64Value": - continue - case ".google.protobuf.FloatValue": - continue - case ".google.protobuf.DoubleValue": - continue - case ".google.protobuf.BoolValue": + if skipRenderingRef(name) { continue } + if opt := msg.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry { continue } @@ -289,7 +281,10 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, } else { kv.Key = f.GetName() } - schema.Properties = append(schema.Properties, kv) + if schema.Properties == nil { + schema.Properties = &swaggerSchemaObjectProperties{} + } + *schema.Properties = append(*schema.Properties, kv) } d[fullyQualifiedNameToSwaggerName(msg.FQMN(), reg)] = schema } @@ -318,16 +313,23 @@ func schemaOfField(f *descriptor.Field, reg *descriptor.Registry, refs refMap) s aggregate = array } + var props *swaggerSchemaObjectProperties + switch ft := fd.GetType(); ft { case pbdescriptor.FieldDescriptorProto_TYPE_ENUM, pbdescriptor.FieldDescriptorProto_TYPE_MESSAGE, pbdescriptor.FieldDescriptorProto_TYPE_GROUP: if wktSchema, ok := wktSchemas[fd.GetTypeName()]; ok { core = wktSchema + + if fd.GetTypeName() == ".google.protobuf.Empty" { + props = &swaggerSchemaObjectProperties{} + } } else { core = schemaCore{ Ref: "#/definitions/" + fullyQualifiedNameToSwaggerName(fd.GetTypeName(), reg), } if refs != nil { refs[fd.GetTypeName()] = struct{}{} + } } default: @@ -352,11 +354,12 @@ func schemaOfField(f *descriptor.Field, reg *descriptor.Registry, refs refMap) s schemaCore: schemaCore{ Type: "object", }, - AdditionalProperties: &swaggerSchemaObject{schemaCore: core}, + AdditionalProperties: &swaggerSchemaObject{Properties: props, schemaCore: core}, } default: ret := swaggerSchemaObject{ schemaCore: core, + Properties: props, } if j, err := extractJSONSchemaFromFieldDescriptor(fd); err == nil { updateSwaggerObjectFromJSONSchema(&ret, j) @@ -657,9 +660,19 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re if len(b.Body.FieldPath) == 0 { schema = swaggerSchemaObject{ - schemaCore: schemaCore{ - Ref: fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg)), - }, + schemaCore: schemaCore{}, + } + + wknSchemaCore, isWkn := wktSchemas[meth.RequestType.FQMN()] + if !isWkn { + schema.Ref = fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg)) + } else { + schema.schemaCore = wknSchemaCore + + // Special workaround for Empty: it's well-known type but wknSchemas only returns schema.schemaCore; but we need to set schema.Properties which is a level higher. + if meth.RequestType.FQMN() == ".google.protobuf.Empty" { + schema.Properties = &swaggerSchemaObjectProperties{} + } } } else { lastField := b.Body.FieldPath[len(b.Body.FieldPath)-1] @@ -701,9 +714,23 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re if b.ResponseBody == nil || len(b.ResponseBody.FieldPath) == 0 { responseSchema = swaggerSchemaObject{ - schemaCore: schemaCore{ - Ref: fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg)), - }, + schemaCore: schemaCore{}, + } + + // Don't link to a full definition for + // empty; it's overly verbose. + // schema.Properties{} renders it as + // well, without a definition + wknSchemaCore, isWkn := wktSchemas[meth.ResponseType.FQMN()] + if !isWkn { + responseSchema.Ref = fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg)) + } else { + responseSchema.schemaCore = wknSchemaCore + + // Special workaround for Empty: it's well-known type but wknSchemas only returns schema.schemaCore; but we need to set schema.Properties which is a level higher. + if meth.ResponseType.FQMN() == ".google.protobuf.Empty" { + responseSchema.Properties = &swaggerSchemaObjectProperties{} + } } } else { // This is resolving the value of response_body in the google.api.HttpRule @@ -1498,6 +1525,7 @@ func addCustomRefs(d swaggerDefinitionsObject, reg *descriptor.Registry, refs re enumMap[fullyQualifiedNameToSwaggerName(ref, reg)] = enum continue } + // ?? Should be either enum or msg } renderMessagesAsDefinition(msgMap, d, reg, refs) diff --git a/protoc-gen-swagger/genswagger/types.go b/protoc-gen-swagger/genswagger/types.go index 9d01e21d15c..b66450cdaa3 100644 --- a/protoc-gen-swagger/genswagger/types.go +++ b/protoc-gen-swagger/genswagger/types.go @@ -199,8 +199,8 @@ func (op swaggerSchemaObjectProperties) MarshalJSON() ([]byte, error) { type swaggerSchemaObject struct { schemaCore // Properties can be recursively defined - Properties swaggerSchemaObjectProperties `json:"properties,omitempty"` - AdditionalProperties *swaggerSchemaObject `json:"additionalProperties,omitempty"` + Properties *swaggerSchemaObjectProperties `json:"properties,omitempty"` + AdditionalProperties *swaggerSchemaObject `json:"additionalProperties,omitempty"` Description string `json:"description,omitempty"` Title string `json:"title,omitempty"`