diff --git a/Makefile b/Makefile index 890f7ede3fd..5242bcca3e0 100644 --- a/Makefile +++ b/Makefile @@ -82,8 +82,7 @@ ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/echo/api_client.go \ $(EXAMPLE_CLIENT_DIR)/echo/api_response.go \ $(EXAMPLE_CLIENT_DIR)/echo/configuration.go \ $(EXAMPLE_CLIENT_DIR)/echo/echo_service_api.go \ - $(EXAMPLE_CLIENT_DIR)/echo/examplepb_simple_message.go \ - $(EXAMPLE_CLIENT_DIR)/echo/examplepb_embedded.go + $(EXAMPLE_CLIENT_DIR)/echo/examplepb_simple_message.go ABE_EXAMPLE_SPEC=examples/proto/examplepb/a_bit_of_everything.swagger.json ABE_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/abe/a_bit_of_everything_nested.go \ $(EXAMPLE_CLIENT_DIR)/abe/a_bit_of_everything_service_api.go \ diff --git a/examples/browser/a_bit_of_everything_service.spec.js b/examples/browser/a_bit_of_everything_service.spec.js index edcbebe11d6..439a35af45e 100644 --- a/examples/browser/a_bit_of_everything_service.spec.js +++ b/examples/browser/a_bit_of_everything_service.spec.js @@ -33,6 +33,7 @@ describe('ABitOfEverythingService', function() { sfixed64_value: "-4611686018427387904", sint32_value: 2147483647, sint64_value: "4611686018427387903", + oneof_value_string: "foo", nonConventionalNameValue: "camelCase", }; @@ -78,7 +79,7 @@ describe('ABitOfEverythingService', function() { { name: "baz", amount: 20 }, ], repeated_string_value: ["a", "b", "c"], - oneof_string: "x", + oneof_value_string: "x", // TODO(yugui) Support enum by name map_value: { a: 1, b: 2 }, mapped_string_value: { a: "x", b: "y" }, diff --git a/examples/clients/abe/a_bit_of_everything_nested.go b/examples/clients/abe/a_bit_of_everything_nested.go index 095e8c5f118..de6c99569cf 100644 --- a/examples/clients/abe/a_bit_of_everything_nested.go +++ b/examples/clients/abe/a_bit_of_everything_nested.go @@ -10,7 +10,6 @@ package abe -// Nested is nested type. type ABitOfEverythingNested struct { // name is nested field. @@ -19,4 +18,10 @@ type ABitOfEverythingNested struct { Amount int64 `json:"amount,omitempty"` Ok NestedDeepEnum `json:"ok,omitempty"` + + DeeperNestedValue SubStringMessage `json:"deeper_nested_value,omitempty"` + + OneofValueDeeperNested SubStringMessage `json:"oneof_value_deeper_nested,omitempty"` + + OneofValueTerminal string `json:"oneof_value_terminal,omitempty"` } 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 19c6fdaa7dd..faa360b9caf 100644 --- a/examples/clients/abe/a_bit_of_everything_service_api.go +++ b/examples/clients/abe/a_bit_of_everything_service_api.go @@ -55,14 +55,15 @@ func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythin * @param sfixed64Value * @param sint32Value * @param sint64Value + * @param oneofValueString * @param nonConventionalNameValue * @return *ExamplepbABitOfEverything */ -func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, oneofValueString string, nonConventionalNameValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/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}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}" + localVarPath := a.Configuration.BasePath + "/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}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{oneof_value_string}/{nonConventionalNameValue}" localVarPath = strings.Replace(localVarPath, "{"+"float_value"+"}", fmt.Sprintf("%v", floatValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"double_value"+"}", fmt.Sprintf("%v", doubleValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"int64_value"+"}", fmt.Sprintf("%v", int64Value), -1) @@ -77,6 +78,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float localVarPath = strings.Replace(localVarPath, "{"+"sfixed64_value"+"}", fmt.Sprintf("%v", sfixed64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"sint32_value"+"}", fmt.Sprintf("%v", sint32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"sint64_value"+"}", fmt.Sprintf("%v", sint64Value), -1) + localVarPath = strings.Replace(localVarPath, "{"+"oneof_value_string"+"}", fmt.Sprintf("%v", oneofValueString), -1) localVarPath = strings.Replace(localVarPath, "{"+"nonConventionalNameValue"+"}", fmt.Sprintf("%v", nonConventionalNameValue), -1) localVarHeaderParams := make(map[string]string) @@ -215,6 +217,153 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( return successPayload, localVarAPIResponse, err } +/** + * + * + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho() (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything;echo" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho10(body ABitOfEverythingNested) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_nested/echo" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho10", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + /** * * @@ -222,7 +371,7 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( * @param body * @return *ExamplepbABitOfEverything */ -func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) DeepPathEcho2(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -279,7 +428,544 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param singleNestedDeeperNestedValueValue + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho3(singleNestedDeeperNestedValueValue string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/single_nested/deeper_nested_value/{single_nested.deeper_nested_value.value}" + localVarPath = strings.Replace(localVarPath, "{"+"single_nested.deeper_nested_value.value"+"}", fmt.Sprintf("%v", singleNestedDeeperNestedValueValue), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho3", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param oneofValueString + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho4(oneofValueString string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_string/echo/{oneof_value_string}" + localVarPath = strings.Replace(localVarPath, "{"+"oneof_value_string"+"}", fmt.Sprintf("%v", oneofValueString), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho4", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param oneofValueNestedName + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho5(oneofValueNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_nested/name/echo/{oneof_value_nested.name}" + localVarPath = strings.Replace(localVarPath, "{"+"oneof_value_nested.name"+"}", fmt.Sprintf("%v", oneofValueNestedName), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho5", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param oneofValueNestedDeeperNestedValueValue + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho6(oneofValueNestedDeeperNestedValueValue string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_nested/deeper_nested_value/value/echo/{oneof_value_nested.deeper_nested_value.value}" + localVarPath = strings.Replace(localVarPath, "{"+"oneof_value_nested.deeper_nested_value.value"+"}", fmt.Sprintf("%v", oneofValueNestedDeeperNestedValueValue), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho6", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param oneofValueNestedOneofValueTerminal + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho7(oneofValueNestedOneofValueTerminal string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_nested/oneof_value_terminal/echo/{oneof_value_nested.oneof_value_terminal}" + localVarPath = strings.Replace(localVarPath, "{"+"oneof_value_nested.oneof_value_terminal"+"}", fmt.Sprintf("%v", oneofValueNestedOneofValueTerminal), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho7", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param oneofValueNestedOneofValueDeeperNestedValue + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho8(oneofValueNestedOneofValueDeeperNestedValue string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_nested/oneof_value_deeper_nested/value/echo/{oneof_value_nested.oneof_value_deeper_nested.value}" + localVarPath = strings.Replace(localVarPath, "{"+"oneof_value_nested.oneof_value_deeper_nested.value"+"}", fmt.Sprintf("%v", oneofValueNestedOneofValueDeeperNestedValue), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho8", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + if localVarHttpResponse != nil { + localVarAPIResponse.Response = localVarHttpResponse.RawResponse + localVarAPIResponse.Payload = localVarHttpResponse.Body() + } + + if err != nil { + return successPayload, localVarAPIResponse, err + } + err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) + return successPayload, localVarAPIResponse, err +} + +/** + * + * + * @param body + * @return *ExamplepbABitOfEverything + */ +func (a ABitOfEverythingServiceApi) DeepPathEcho9(body string) (*ExamplepbABitOfEverything, *APIResponse, error) { + + var localVarHttpMethod = strings.ToUpper("Post") + // create path and map variables + localVarPath := a.Configuration.BasePath + "/v2/example/oneof_value_string/echo" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := make(map[string]string) + var localVarPostBody interface{} + var localVarFileName string + var localVarFileBytes []byte + // authentication '(OAuth2)' required + // oauth required + if a.Configuration.AccessToken != ""{ + localVarHeaderParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // authentication '(BasicAuth)' required + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + // authentication '(ApiKeyAuth)' required + // set key with prefix in header + localVarHeaderParams["X-API-Key"] = a.Configuration.GetAPIKeyWithPrefix("X-API-Key") + // add default headers if any + for key := range a.Configuration.DefaultHeader { + localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] + } + + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } + + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + "application/x-foo-mime", + } + + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + var successPayload = new(ExamplepbABitOfEverything) + localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + + var localVarURL, _ = url.Parse(localVarPath) + localVarURL.RawQuery = localVarQueryParams.Encode() + var localVarAPIResponse = &APIResponse{Operation: "DeepPathEcho9", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -517,6 +1203,9 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb * @param singleNestedName name is nested field. * @param singleNestedAmount * @param singleNestedOk - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param singleNestedDeeperNestedValueValue + * @param singleNestedOneofValueDeeperNestedValue + * @param singleNestedOneofValueTerminal * @param floatValue * @param doubleValue * @param int64Value @@ -534,13 +1223,19 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb * @param sint32Value * @param sint64Value * @param repeatedStringValue - * @param oneofString + * @param oneofValueString tag 20 is reserved. + * @param oneofValueNestedName name is nested field. + * @param oneofValueNestedAmount + * @param oneofValueNestedOk - FALSE: FALSE is false. - TRUE: TRUE is true. + * @param oneofValueNestedDeeperNestedValueValue + * @param oneofValueNestedOneofValueDeeperNestedValue + * @param oneofValueNestedOneofValueTerminal * @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 */ -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, 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, singleNestedDeeperNestedValueValue string, singleNestedOneofValueDeeperNestedValue string, singleNestedOneofValueTerminal 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, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofValueString string, oneofValueNestedName string, oneofValueNestedAmount int64, oneofValueNestedOk string, oneofValueNestedDeeperNestedValueValue string, oneofValueNestedOneofValueDeeperNestedValue string, oneofValueNestedOneofValueTerminal string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*ProtobufEmpty, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -573,6 +1268,9 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin localVarQueryParams.Add("single_nested.name", a.Configuration.APIClient.ParameterToString(singleNestedName, "")) localVarQueryParams.Add("single_nested.amount", a.Configuration.APIClient.ParameterToString(singleNestedAmount, "")) localVarQueryParams.Add("single_nested.ok", a.Configuration.APIClient.ParameterToString(singleNestedOk, "")) + localVarQueryParams.Add("single_nested.deeper_nested_value.value", a.Configuration.APIClient.ParameterToString(singleNestedDeeperNestedValueValue, "")) + localVarQueryParams.Add("single_nested.oneof_value_deeper_nested.value", a.Configuration.APIClient.ParameterToString(singleNestedOneofValueDeeperNestedValue, "")) + localVarQueryParams.Add("single_nested.oneof_value_terminal", a.Configuration.APIClient.ParameterToString(singleNestedOneofValueTerminal, "")) localVarQueryParams.Add("float_value", a.Configuration.APIClient.ParameterToString(floatValue, "")) localVarQueryParams.Add("double_value", a.Configuration.APIClient.ParameterToString(doubleValue, "")) localVarQueryParams.Add("int64_value", a.Configuration.APIClient.ParameterToString(int64Value, "")) @@ -592,7 +1290,13 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin var repeatedStringValueCollectionFormat = "csv" localVarQueryParams.Add("repeated_string_value", a.Configuration.APIClient.ParameterToString(repeatedStringValue, repeatedStringValueCollectionFormat)) - localVarQueryParams.Add("oneof_string", a.Configuration.APIClient.ParameterToString(oneofString, "")) + localVarQueryParams.Add("oneof_value_string", a.Configuration.APIClient.ParameterToString(oneofValueString, "")) + localVarQueryParams.Add("oneof_value_nested.name", a.Configuration.APIClient.ParameterToString(oneofValueNestedName, "")) + localVarQueryParams.Add("oneof_value_nested.amount", a.Configuration.APIClient.ParameterToString(oneofValueNestedAmount, "")) + localVarQueryParams.Add("oneof_value_nested.ok", a.Configuration.APIClient.ParameterToString(oneofValueNestedOk, "")) + localVarQueryParams.Add("oneof_value_nested.deeper_nested_value.value", a.Configuration.APIClient.ParameterToString(oneofValueNestedDeeperNestedValueValue, "")) + localVarQueryParams.Add("oneof_value_nested.oneof_value_deeper_nested.value", a.Configuration.APIClient.ParameterToString(oneofValueNestedOneofValueDeeperNestedValue, "")) + localVarQueryParams.Add("oneof_value_nested.oneof_value_terminal", a.Configuration.APIClient.ParameterToString(oneofValueNestedOneofValueTerminal, "")) localVarQueryParams.Add("nonConventionalNameValue", a.Configuration.APIClient.ParameterToString(nonConventionalNameValue, "")) localVarQueryParams.Add("timestamp_value", a.Configuration.APIClient.ParameterToString(timestampValue, "")) var repeatedEnumValueCollectionFormat = "csv" diff --git a/examples/clients/abe/examplepb_a_bit_of_everything.go b/examples/clients/abe/examplepb_a_bit_of_everything.go index cb6fb3a487d..394887fa3e9 100644 --- a/examples/clients/abe/examplepb_a_bit_of_everything.go +++ b/examples/clients/abe/examplepb_a_bit_of_everything.go @@ -56,9 +56,9 @@ type ExamplepbABitOfEverything struct { RepeatedStringValue []string `json:"repeated_string_value,omitempty"` - OneofEmpty ProtobufEmpty `json:"oneof_empty,omitempty"` + OneofValueString string `json:"oneof_value_string,omitempty"` - OneofString string `json:"oneof_string,omitempty"` + OneofValueNested ABitOfEverythingNested `json:"oneof_value_nested,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"map_value,omitempty"` diff --git a/examples/clients/echo/BUILD.bazel b/examples/clients/echo/BUILD.bazel index 090b56aafab..99243f3cded 100644 --- a/examples/clients/echo/BUILD.bazel +++ b/examples/clients/echo/BUILD.bazel @@ -9,7 +9,6 @@ go_library( "api_response.go", "configuration.go", "echo_service_api.go", - "examplepb_embedded.go", "examplepb_simple_message.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/echo", diff --git a/examples/clients/echo/echo_service_api.go b/examples/clients/echo/echo_service_api.go index 775d0b3a7e6..41316dce169 100644 --- a/examples/clients/echo/echo_service_api.go +++ b/examples/clients/echo/echo_service_api.go @@ -104,16 +104,9 @@ func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, * * @param id * @param num - * @param lineNum - * @param lang - * @param statusProgress - * @param statusNote - * @param en - * @param noProgress - * @param noNote * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo2(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo2(id string, num string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -131,13 +124,6 @@ func (a EchoServiceApi) Echo2(id string, num string, lineNum string, lang string for key := range a.Configuration.DefaultHeader { localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] } - localVarQueryParams.Add("line_num", a.Configuration.APIClient.ParameterToString(lineNum, "")) - localVarQueryParams.Add("lang", a.Configuration.APIClient.ParameterToString(lang, "")) - localVarQueryParams.Add("status.progress", a.Configuration.APIClient.ParameterToString(statusProgress, "")) - localVarQueryParams.Add("status.note", a.Configuration.APIClient.ParameterToString(statusNote, "")) - localVarQueryParams.Add("en", a.Configuration.APIClient.ParameterToString(en, "")) - localVarQueryParams.Add("no.progress", a.Configuration.APIClient.ParameterToString(noProgress, "")) - localVarQueryParams.Add("no.note", a.Configuration.APIClient.ParameterToString(noNote, "")) // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } @@ -175,233 +161,6 @@ func (a EchoServiceApi) Echo2(id string, num string, lineNum string, lang string return successPayload, localVarAPIResponse, err } -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id - * @param num - * @param lang - * @param lineNum - * @param statusProgress - * @param statusNote - * @param en - * @param noProgress - * @param noNote - * @return *ExamplepbSimpleMessage - */ -func (a EchoServiceApi) Echo3(id string, num string, lang string, lineNum string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { - - var localVarHttpMethod = strings.ToUpper("Get") - // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}/{lang}" - localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) - localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) - localVarPath = strings.Replace(localVarPath, "{"+"lang"+"}", fmt.Sprintf("%v", lang), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := make(map[string]string) - var localVarPostBody interface{} - var localVarFileName string - var localVarFileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] - } - localVarQueryParams.Add("line_num", a.Configuration.APIClient.ParameterToString(lineNum, "")) - localVarQueryParams.Add("status.progress", a.Configuration.APIClient.ParameterToString(statusProgress, "")) - localVarQueryParams.Add("status.note", a.Configuration.APIClient.ParameterToString(statusNote, "")) - localVarQueryParams.Add("en", a.Configuration.APIClient.ParameterToString(en, "")) - localVarQueryParams.Add("no.progress", a.Configuration.APIClient.ParameterToString(noProgress, "")) - localVarQueryParams.Add("no.note", a.Configuration.APIClient.ParameterToString(noNote, "")) - - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } - - // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } - - // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - var successPayload = new(ExamplepbSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo3", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() - } - - if err != nil { - return successPayload, localVarAPIResponse, err - } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err -} - -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id - * @param lineNum - * @param statusNote - * @param num - * @param lang - * @param statusProgress - * @param en - * @param noProgress - * @return *ExamplepbSimpleMessage - */ -func (a EchoServiceApi) Echo4(id string, lineNum string, statusNote string, num string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { - - var localVarHttpMethod = strings.ToUpper("Get") - // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo1/{id}/{line_num}/{status.note}" - localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) - localVarPath = strings.Replace(localVarPath, "{"+"line_num"+"}", fmt.Sprintf("%v", lineNum), -1) - localVarPath = strings.Replace(localVarPath, "{"+"status.note"+"}", fmt.Sprintf("%v", statusNote), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := make(map[string]string) - var localVarPostBody interface{} - var localVarFileName string - var localVarFileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] - } - localVarQueryParams.Add("num", a.Configuration.APIClient.ParameterToString(num, "")) - localVarQueryParams.Add("lang", a.Configuration.APIClient.ParameterToString(lang, "")) - localVarQueryParams.Add("status.progress", a.Configuration.APIClient.ParameterToString(statusProgress, "")) - localVarQueryParams.Add("en", a.Configuration.APIClient.ParameterToString(en, "")) - localVarQueryParams.Add("no.progress", a.Configuration.APIClient.ParameterToString(noProgress, "")) - - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } - - // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } - - // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - var successPayload = new(ExamplepbSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo4", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() - } - - if err != nil { - return successPayload, localVarAPIResponse, err - } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err -} - -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param noNote - * @param id Id represents the message identifier. - * @param num - * @param lineNum - * @param lang - * @param statusProgress - * @param en - * @param noProgress - * @return *ExamplepbSimpleMessage - */ -func (a EchoServiceApi) Echo5(noNote string, id string, num string, lineNum string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { - - var localVarHttpMethod = strings.ToUpper("Get") - // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo2/{no.note}" - localVarPath = strings.Replace(localVarPath, "{"+"no.note"+"}", fmt.Sprintf("%v", noNote), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := make(map[string]string) - var localVarPostBody interface{} - var localVarFileName string - var localVarFileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] - } - localVarQueryParams.Add("id", a.Configuration.APIClient.ParameterToString(id, "")) - localVarQueryParams.Add("num", a.Configuration.APIClient.ParameterToString(num, "")) - localVarQueryParams.Add("line_num", a.Configuration.APIClient.ParameterToString(lineNum, "")) - localVarQueryParams.Add("lang", a.Configuration.APIClient.ParameterToString(lang, "")) - localVarQueryParams.Add("status.progress", a.Configuration.APIClient.ParameterToString(statusProgress, "")) - localVarQueryParams.Add("en", a.Configuration.APIClient.ParameterToString(en, "")) - localVarQueryParams.Add("no.progress", a.Configuration.APIClient.ParameterToString(noProgress, "")) - - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } - - // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } - - // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - var successPayload = new(ExamplepbSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo5", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() - } - - if err != nil { - return successPayload, localVarAPIResponse, err - } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err -} - /** * EchoBody method receives a simple message and returns it. * @@ -468,16 +227,9 @@ func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleM * * @param id Id represents the message identifier. * @param num - * @param lineNum - * @param lang - * @param statusProgress - * @param statusNote - * @param en - * @param noProgress - * @param noNote * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) EchoDelete(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) EchoDelete(id string, num string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables @@ -495,13 +247,6 @@ func (a EchoServiceApi) EchoDelete(id string, num string, lineNum string, lang s } localVarQueryParams.Add("id", a.Configuration.APIClient.ParameterToString(id, "")) localVarQueryParams.Add("num", a.Configuration.APIClient.ParameterToString(num, "")) - localVarQueryParams.Add("line_num", a.Configuration.APIClient.ParameterToString(lineNum, "")) - localVarQueryParams.Add("lang", a.Configuration.APIClient.ParameterToString(lang, "")) - localVarQueryParams.Add("status.progress", a.Configuration.APIClient.ParameterToString(statusProgress, "")) - localVarQueryParams.Add("status.note", a.Configuration.APIClient.ParameterToString(statusNote, "")) - localVarQueryParams.Add("en", a.Configuration.APIClient.ParameterToString(en, "")) - localVarQueryParams.Add("no.progress", a.Configuration.APIClient.ParameterToString(noProgress, "")) - localVarQueryParams.Add("no.note", a.Configuration.APIClient.ParameterToString(noNote, "")) // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } diff --git a/examples/clients/echo/examplepb_embedded.go b/examples/clients/echo/examplepb_embedded.go deleted file mode 100644 index 4b5fe265ac9..00000000000 --- a/examples/clients/echo/examplepb_embedded.go +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Echo Service - * - * Echo Service API consists of a single service which returns a message. - * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git - */ - -package echo - -// Embedded represents a message embedded in SimpleMessage. -type ExamplepbEmbedded struct { - - Progress string `json:"progress,omitempty"` - - Note string `json:"note,omitempty"` -} diff --git a/examples/clients/echo/examplepb_simple_message.go b/examples/clients/echo/examplepb_simple_message.go index 366a6876665..98eb8325083 100644 --- a/examples/clients/echo/examplepb_simple_message.go +++ b/examples/clients/echo/examplepb_simple_message.go @@ -17,14 +17,4 @@ type ExamplepbSimpleMessage struct { Id string `json:"id,omitempty"` Num string `json:"num,omitempty"` - - LineNum string `json:"line_num,omitempty"` - - Lang string `json:"lang,omitempty"` - - Status ExamplepbEmbedded `json:"status,omitempty"` - - En string `json:"en,omitempty"` - - No ExamplepbEmbedded `json:"no,omitempty"` } diff --git a/examples/integration/client_test.go b/examples/integration/client_test.go index b49a2f31fff..4f405ec29c7 100644 --- a/examples/integration/client_test.go +++ b/examples/integration/client_test.go @@ -72,6 +72,7 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) { Sfixed64Value: "-4611686018427387904", Sint32Value: 2147483647, Sint64Value: "4611686018427387903", + OneofValueString: "bar", NonConventionalNameValue: "camelCase", } resp, _, err := cl.Create( @@ -89,6 +90,7 @@ func testABEClientCreate(t *testing.T, cl *abe.ABitOfEverythingServiceApi) { want.Sfixed64Value, want.Sint32Value, want.Sint64Value, + want.OneofValueString, want.NonConventionalNameValue, ) if err != nil { @@ -135,7 +137,7 @@ func testABEClientCreateBody(t *testing.T, cl *abe.ABitOfEverythingServiceApi) { }, }, RepeatedStringValue: []string{"a", "b", "c"}, - OneofString: "x", + OneofValueString: "x", MapValue: map[string]abe.ExamplepbNumericEnum{ // "a": abe.ExamplepbNumericEnum_ONE, // "b": abe.ExamplepbNumericEnum_ZERO, diff --git a/examples/integration/integration_test.go b/examples/integration/integration_test.go index 0c2885c4557..79b56d7909e 100644 --- a/examples/integration/integration_test.go +++ b/examples/integration/integration_test.go @@ -29,6 +29,8 @@ type errorBody struct { Details []interface{} `json:"details"` } +// TestEcho tests the most fundamental functionalities of marshaling requests +// an unmarshaling responses. func TestEcho(t *testing.T) { if testing.Short() { t.Skip() @@ -36,9 +38,6 @@ func TestEcho(t *testing.T) { } testEcho(t, 8080, "application/json") - testEchoOneof(t, 8080, "application/json") - testEchoOneof1(t, 8080, "application/json") - testEchoOneof2(t, 8080, "application/json") testEchoBody(t, 8080) } @@ -68,6 +67,7 @@ func TestForwardResponseOption(t *testing.T) { testEcho(t, 8081, "application/vnd.docker.plugins.v1.1+json") } +// testEcho is a part of TestEcho which deals with path parameters func testEcho(t *testing.T, port int, contentType string) { url := fmt.Sprintf("http://localhost:%d/v1/example/echo/myid", port) resp, err := http.Post(url, "application/json", strings.NewReader("{}")) @@ -101,105 +101,7 @@ func testEcho(t *testing.T, port int, contentType string) { } } -func testEchoOneof(t *testing.T, port int, contentType string) { - url := fmt.Sprintf("http://localhost:%d/v1/example/echo/myid/10/golang", port) - resp, err := http.Get(url) - if err != nil { - t.Errorf("http.Get(%q) failed with %v; want success", url, err) - return - } - defer resp.Body.Close() - buf, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Errorf("iotuil.ReadAll(resp.Body) failed with %v; want success", err) - return - } - - if got, want := resp.StatusCode, http.StatusOK; got != want { - t.Errorf("resp.StatusCode = %d; want %d", got, want) - t.Logf("%s", buf) - } - - var msg gw.SimpleMessage - if err := jsonpb.UnmarshalString(string(buf), &msg); err != nil { - t.Errorf("jsonpb.UnmarshalString(%s, &msg) failed with %v; want success", buf, err) - return - } - if got, want := msg.GetLang(), "golang"; got != want { - t.Errorf("msg.GetLang() = %q; want %q", got, want) - } - - if value := resp.Header.Get("Content-Type"); value != contentType { - t.Errorf("Content-Type was %s, wanted %s", value, contentType) - } -} - -func testEchoOneof1(t *testing.T, port int, contentType string) { - url := fmt.Sprintf("http://localhost:%d/v1/example/echo1/myid/10/golang", port) - resp, err := http.Get(url) - if err != nil { - t.Errorf("http.Get(%q) failed with %v; want success", url, err) - return - } - defer resp.Body.Close() - buf, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Errorf("iotuil.ReadAll(resp.Body) failed with %v; want success", err) - return - } - - if got, want := resp.StatusCode, http.StatusOK; got != want { - t.Errorf("resp.StatusCode = %d; want %d", got, want) - t.Logf("%s", buf) - } - - var msg gw.SimpleMessage - if err := jsonpb.UnmarshalString(string(buf), &msg); err != nil { - t.Errorf("jsonpb.UnmarshalString(%s, &msg) failed with %v; want success", buf, err) - return - } - if got, want := msg.GetStatus().GetNote(), "golang"; got != want { - t.Errorf("msg.GetStatus().GetNote() = %q; want %q", got, want) - } - - if value := resp.Header.Get("Content-Type"); value != contentType { - t.Errorf("Content-Type was %s, wanted %s", value, contentType) - } -} - -func testEchoOneof2(t *testing.T, port int, contentType string) { - url := fmt.Sprintf("http://localhost:%d/v1/example/echo2/golang", port) - resp, err := http.Get(url) - if err != nil { - t.Errorf("http.Get(%q) failed with %v; want success", url, err) - return - } - defer resp.Body.Close() - buf, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Errorf("iotuil.ReadAll(resp.Body) failed with %v; want success", err) - return - } - - if got, want := resp.StatusCode, http.StatusOK; got != want { - t.Errorf("resp.StatusCode = %d; want %d", got, want) - t.Logf("%s", buf) - } - - var msg gw.SimpleMessage - if err := jsonpb.UnmarshalString(string(buf), &msg); err != nil { - t.Errorf("jsonpb.UnmarshalString(%s, &msg) failed with %v; want success", buf, err) - return - } - if got, want := msg.GetNo().GetNote(), "golang"; got != want { - t.Errorf("msg.GetNo().GetNote() = %q; want %q", got, want) - } - - if value := resp.Header.Get("Content-Type"); value != contentType { - t.Errorf("Content-Type was %s, wanted %s", value, contentType) - } -} - +// testEchoBody is a part of TestEcho which deals with a body parameter. func testEchoBody(t *testing.T, port int) { sent := gw.SimpleMessage{Id: "example"} var m jsonpb.Marshaler @@ -250,6 +152,11 @@ func testEchoBody(t *testing.T, port int) { } } +// TestABE covers more than TestEcho. +// It covers (1) various HTTP methods; (2) various HTTP status codes +// (3) streaming requests and responses; (4) various types of fields; +// (5) various depths of nested fields; and (6) even more features like +// additional_bindings func TestABE(t *testing.T) { if testing.Short() { t.Skip() @@ -267,7 +174,9 @@ func TestABE(t *testing.T) { testAdditionalBindings(t, 8080) } +// testABECreate tests path parameters with various types of fields. func testABECreate(t *testing.T, port int) { + const oneofStr = "bar" want := gw.ABitOfEverything{ FloatValue: 1.5, DoubleValue: 2.5, @@ -283,9 +192,10 @@ func testABECreate(t *testing.T, port int) { Sfixed64Value: -4611686018427387904, Sint32Value: 2147483647, Sint64Value: 4611686018427387903, + OneofValue: &gw.ABitOfEverything_OneofValueString{oneofStr}, NonConventionalNameValue: "camelCase", } - url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/%f/%f/%d/separator/%d/%d/%d/%d/%v/%s/%d/%d/%d/%d/%d/%s", port, want.FloatValue, want.DoubleValue, want.Int64Value, want.Uint64Value, want.Int32Value, want.Fixed64Value, want.Fixed32Value, want.BoolValue, want.StringValue, want.Uint32Value, want.Sfixed32Value, want.Sfixed64Value, want.Sint32Value, want.Sint64Value, want.NonConventionalNameValue) + url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/%f/%f/%d/separator/%d/%d/%d/%d/%v/%s/%d/%d/%d/%d/%d/%s/%s", port, want.FloatValue, want.DoubleValue, want.Int64Value, want.Uint64Value, want.Int32Value, want.Fixed64Value, want.Fixed32Value, want.BoolValue, want.StringValue, want.Uint32Value, want.Sfixed32Value, want.Sfixed64Value, want.Sint32Value, want.Sint64Value, oneofStr, want.NonConventionalNameValue) resp, err := http.Post(url, "application/json", strings.NewReader("{}")) if err != nil { @@ -318,6 +228,7 @@ func testABECreate(t *testing.T, port int) { } } +// testABECreateBody tests body parameters with various types of fields. func testABECreateBody(t *testing.T, port int) { want := gw.ABitOfEverything{ FloatValue: 1.5, @@ -347,8 +258,8 @@ func testABECreateBody(t *testing.T, port int) { }, }, RepeatedStringValue: []string{"a", "b", "c"}, - OneofValue: &gw.ABitOfEverything_OneofString{ - OneofString: "x", + OneofValue: &gw.ABitOfEverything_OneofValueString{ + OneofValueString: "x", }, MapValue: map[string]gw.NumericEnum{ "a": gw.NumericEnum_ONE, @@ -401,6 +312,7 @@ func testABECreateBody(t *testing.T, port int) { } } +// testABEBulkCreate tests client-streaming func testABEBulkCreate(t *testing.T, port int) { count := 0 r, w := io.Pipe() @@ -488,6 +400,7 @@ func testABEBulkCreate(t *testing.T, port int) { } } +// testABELookup tests unary call func testABELookup(t *testing.T, port int) { url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) cresp, err := http.Post(url, "application/json", strings.NewReader(` @@ -543,6 +456,8 @@ func testABELookup(t *testing.T, port int) { } } +// testABELookupNotFound tests HTTP status codes other than StatusOK. +// More coverage on status codes should be done in runtime/error_test.go. func testABELookupNotFound(t *testing.T, port int) { url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) uuid := "not_exist" @@ -593,6 +508,7 @@ func testABELookupNotFound(t *testing.T, port int) { } } +// testABEList tests server-streaming. func testABEList(t *testing.T, port int) { url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) resp, err := http.Get(url) @@ -644,6 +560,7 @@ func testABEList(t *testing.T, port int) { } } +// testABEBulkEcho tests bidi-streaming func testABEBulkEcho(t *testing.T, port int) { reqr, reqw := io.Pipe() var wg sync.WaitGroup @@ -722,6 +639,8 @@ func testABEBulkEcho(t *testing.T, port int) { } } +// testABEBulkEchoZeroLength covers an edge case of testABEBulkEcho that the length of +// the chunked stream is zero. func testABEBulkEchoZeroLength(t *testing.T, port int) { url := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/echo", port) req, err := http.NewRequest("POST", url, bytes.NewReader(nil)) @@ -754,6 +673,8 @@ func testABEBulkEchoZeroLength(t *testing.T, port int) { } } +// testAdditionalBindings tests if additional_bindings works as fine as the +// primary binding. func testAdditionalBindings(t *testing.T, port int) { for i, f := range []func() *http.Response{ func() *http.Response { @@ -825,6 +746,255 @@ func testAdditionalBindings(t *testing.T, port int) { } } +// TestDeepFields tests deeply nested fields in path parameters. +// +// NOTE: deeply nested fields are not allowed in body parameters. +// c.f. third_party/googleapis/google/api/http.proto +// > the referred field must not be a repeated field and must be +// > present at the top-level of request message type. +func TestDeepFields(t *testing.T) { + const base = "http://localhost:8080" + + for i, spec := range []struct { + path string + payload string + want gw.ABitOfEverything + }{ + { + path: "/v1/example/a_bit_of_everything/foo", + want: gw.ABitOfEverything{ + SingleNested: &gw.ABitOfEverything_Nested{ + Name: "foo", + }, + }, + }, + { + path: "/v2/example/single_nested/deeper_nested_value/foo", + want: gw.ABitOfEverything{ + SingleNested: &gw.ABitOfEverything_Nested{ + DeeperNestedValue: &sub.StringMessage{ + Value: proto.String("foo"), + }, + }, + }, + }, + } { + url := base + spec.path + resp, err := http.Post(url, "application/json", strings.NewReader(spec.payload)) + if err != nil { + t.Errorf("http.Post(%q) failed with %v; want success; at i=%d", url, err, i) + return + } + defer resp.Body.Close() + buf, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Errorf("iotuil.ReadAll(resp.Body) failed with %v; want success; at i=%d", err, i) + return + } + + if got, want := resp.StatusCode, http.StatusOK; got != want { + t.Errorf("resp.StatusCode = %d; want %d; at i=%d", got, want, i) + t.Logf("%s", buf) + } + + var got gw.ABitOfEverything + if err := jsonpb.UnmarshalString(string(buf), &got); err != nil { + t.Errorf("jsonpb.UnmarshalString(%s, &msg) failed with %v; want success; at i=%d", buf, err, i) + return + } + if !reflect.DeepEqual(got, spec.want) { + t.Errorf("got = %v; want %v; at i=%d", got, spec.want, i) + } + } +} + +func TestOneof(t *testing.T) { + const base = "http://localhost:8080" + + for i, spec := range []struct { + path string + payload string + want gw.ABitOfEverything + }{ + // path param: primitive field in a oneof clause. + { + path: "/v2/example/oneof_value_string/echo/foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueString{"foo"}, + }, + }, + // path param: primitive field in a message field in a oneof clause + { + path: "/v2/example/oneof_value_nested/name/echo/foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + Name: "foo", + }, + }, + }, + }, + // path param: primitive field in a message field in a message field in a oneof clause + { + path: "/v2/example/oneof_value_nested/deeper_nested_value/value/echo/foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + DeeperNestedValue: &sub.StringMessage{ + Value: proto.String("foo"), + }, + }, + }, + }, + }, + // path param: primitive field in a oneof clause in a message field in a oneof clause. + { + path: "/v2/example/oneof_value_nested/oneof_value_terminal/echo/foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + OneofValue: &gw.ABitOfEverything_Nested_OneofValueTerminal{ + "foo", + }, + }, + }, + }, + }, + // path param: primitive field in a message field in a oneof clause in a message field in a oneof clause. + { + path: "/v2/example/oneof_value_nested/oneof_value_deeper_nested/value/echo/foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + OneofValue: &gw.ABitOfEverything_Nested_OneofValueDeeperNested{ + &sub.StringMessage{ + Value: proto.String("foo"), + }, + }, + }, + }, + }, + }, + + // body param: primitive field in a oneof clause + { + path: "/v2/example/oneof_value_string/echo", + payload: `"foo"`, + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueString{"foo"}, + }, + }, + // body param: message field in a oneof clause + { + path: "/v2/example/oneof_value_nested/echo", + payload: ` + { + "name": "foo", + "amount": 123 + } + `, + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + Name: "foo", + Amount: 123, + }, + }, + }, + }, + // NOTE: deeply nested fields are not allowed in body by spec. + + // query param: primitive field in a oneof clause + { + path: "/v1/example/a_bit_of_everything;echo?oneof_value_string=foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueString{"foo"}, + }, + }, + // path param: primitive field in a message field in a oneof clause + { + path: "/v1/example/a_bit_of_everything;echo?oneof_value_nested%2Ename=foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + Name: "foo", + }, + }, + }, + }, + // path param: primitive field in a message field in a message field in a oneof clause + { + path: "/v1/example/a_bit_of_everything;echo?oneof_value_nested%2Edeeper_nested_value%2Evalue=foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + DeeperNestedValue: &sub.StringMessage{ + Value: proto.String("foo"), + }, + }, + }, + }, + }, + // path param: primitive field in a oneof clause in a message field in a oneof clause. + { + path: "/v1/example/a_bit_of_everything;echo?oneof_value_nested%2Eoneof_value_terminal=foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + OneofValue: &gw.ABitOfEverything_Nested_OneofValueTerminal{ + "foo", + }, + }, + }, + }, + }, + // path param: primitive field in a message field in a oneof clause in a message field in a oneof clause. + { + path: "/v1/example/a_bit_of_everything;echo?oneof_value_nested%2Eoneof_value_deeper_nested%2Evalue=foo", + want: gw.ABitOfEverything{ + OneofValue: &gw.ABitOfEverything_OneofValueNested{ + &gw.ABitOfEverything_Nested{ + OneofValue: &gw.ABitOfEverything_Nested_OneofValueDeeperNested{ + &sub.StringMessage{ + Value: proto.String("foo"), + }, + }, + }, + }, + }, + }, + } { + url := base + spec.path + resp, err := http.Post(url, "application/json", strings.NewReader(spec.payload)) + if err != nil { + t.Errorf("http.Post(%q) failed with %v; want success; at i=%d", url, err, i) + return + } + defer resp.Body.Close() + buf, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Errorf("iotuil.ReadAll(resp.Body) failed with %v; want success; at i=%d", err, i) + return + } + + if got, want := resp.StatusCode, http.StatusOK; got != want { + t.Errorf("resp.StatusCode = %d; want %d; at i=%d", got, want, i) + t.Logf("%s", buf) + } + + var got gw.ABitOfEverything + if err := jsonpb.UnmarshalString(string(buf), &got); err != nil { + t.Errorf("jsonpb.UnmarshalString(%s, &msg) failed with %v; want success; at i=%d", buf, err, i) + return + } + if !reflect.DeepEqual(got, spec.want) { + t.Errorf("got = %v; want %v; at i=%d", &got, &spec.want, i) + } + } +} + +// TestTimeout tests if timeout metadata propagates to the grpc backend server. +// TODO(yugui) Check if the timeout is actually earlier than the default HTTP timeout. func TestTimeout(t *testing.T) { url := "http://localhost:8080/v2/example/timeout" req, err := http.NewRequest("GET", url, nil) @@ -845,6 +1015,8 @@ func TestTimeout(t *testing.T) { } } +// TestErrorWithDetails tests error details set by grpc server are available +// in the HTTP response. func TestErrorWithDetails(t *testing.T) { url := "http://localhost:8080/v2/example/errorwithdetails" resp, err := http.Get(url) @@ -905,6 +1077,9 @@ func TestErrorWithDetails(t *testing.T) { } } +// TestPostWithEmptyBody covers an edge-case that the request body is empty. +// It should be valid, in particular, all fields are specified in path +// parameters and query parameters. func TestPostWithEmptyBody(t *testing.T) { url := "http://localhost:8080/v2/example/postwithemptybody/name" rep, err := http.Post(url, "application/json", nil) @@ -921,6 +1096,7 @@ func TestPostWithEmptyBody(t *testing.T) { } } +// TestUnknownPath tests if the router rejects unknown paths. func TestUnknownPath(t *testing.T) { url := "http://localhost:8080" resp, err := http.Post(url, "application/json", strings.NewReader("{}")) @@ -941,6 +1117,8 @@ func TestUnknownPath(t *testing.T) { } } +// TestUnknownPath tests if the router rejects unsupported methods on a +// known path. func TestMethodNotAllowed(t *testing.T) { url := "http://localhost:8080/v1/example/echo/myid" resp, err := http.Get(url) @@ -961,6 +1139,7 @@ func TestMethodNotAllowed(t *testing.T) { } } +// TestInvalidArgument tests if the decoder rejects a malformed path parameter. func TestInvalidArgument(t *testing.T) { url := "http://localhost:8080/v1/example/echo/myid/not_int64" resp, err := http.Get(url) diff --git a/examples/proto/examplepb/a_bit_of_everything.pb.go b/examples/proto/examplepb/a_bit_of_everything.pb.go index 23703e51d83..d11f1800c4e 100644 --- a/examples/proto/examplepb/a_bit_of_everything.pb.go +++ b/examples/proto/examplepb/a_bit_of_everything.pb.go @@ -75,7 +75,7 @@ func (ABitOfEverything_Nested_DeepEnum) EnumDescriptor() ([]byte, []int) { } // Intentionaly complicated message type to cover much features of Protobuf. -// NEXT ID: 30 +// NEXT ID: 31 type ABitOfEverything struct { SingleNested *ABitOfEverything_Nested `protobuf:"bytes,25,opt,name=single_nested,json=singleNested" json:"single_nested,omitempty"` Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"` @@ -98,8 +98,8 @@ type ABitOfEverything struct { Sint64Value int64 `protobuf:"zigzag64,18,opt,name=sint64_value,json=sint64Value" json:"sint64_value,omitempty"` RepeatedStringValue []string `protobuf:"bytes,19,rep,name=repeated_string_value,json=repeatedStringValue" json:"repeated_string_value,omitempty"` // Types that are valid to be assigned to OneofValue: - // *ABitOfEverything_OneofEmpty - // *ABitOfEverything_OneofString + // *ABitOfEverything_OneofValueString + // *ABitOfEverything_OneofValueNested OneofValue isABitOfEverything_OneofValue `protobuf_oneof:"oneof_value"` MapValue map[string]NumericEnum `protobuf:"bytes,22,rep,name=map_value,json=mapValue" json:"map_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=grpc.gateway.examples.examplepb.NumericEnum"` MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` @@ -119,15 +119,15 @@ type isABitOfEverything_OneofValue interface { isABitOfEverything_OneofValue() } -type ABitOfEverything_OneofEmpty struct { - OneofEmpty *google_protobuf1.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` +type ABitOfEverything_OneofValueString struct { + OneofValueString string `protobuf:"bytes,21,opt,name=oneof_value_string,json=oneofValueString,oneof"` } -type ABitOfEverything_OneofString struct { - OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,oneof"` +type ABitOfEverything_OneofValueNested struct { + OneofValueNested *ABitOfEverything_Nested `protobuf:"bytes,30,opt,name=oneof_value_nested,json=oneofValueNested,oneof"` } -func (*ABitOfEverything_OneofEmpty) isABitOfEverything_OneofValue() {} -func (*ABitOfEverything_OneofString) isABitOfEverything_OneofValue() {} +func (*ABitOfEverything_OneofValueString) isABitOfEverything_OneofValue() {} +func (*ABitOfEverything_OneofValueNested) isABitOfEverything_OneofValue() {} func (m *ABitOfEverything) GetOneofValue() isABitOfEverything_OneofValue { if m != nil { @@ -276,18 +276,18 @@ func (m *ABitOfEverything) GetRepeatedStringValue() []string { return nil } -func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf1.Empty { - if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { - return x.OneofEmpty +func (m *ABitOfEverything) GetOneofValueString() string { + if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofValueString); ok { + return x.OneofValueString } - return nil + return "" } -func (m *ABitOfEverything) GetOneofString() string { - if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofString); ok { - return x.OneofString +func (m *ABitOfEverything) GetOneofValueNested() *ABitOfEverything_Nested { + if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofValueNested); ok { + return x.OneofValueNested } - return "" + return nil } func (m *ABitOfEverything) GetMapValue() map[string]NumericEnum { @@ -335,8 +335,8 @@ func (m *ABitOfEverything) GetRepeatedEnumValue() []NumericEnum { // XXX_OneofFuncs is for the internal use of the proto package. func (*ABitOfEverything) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _ABitOfEverything_OneofMarshaler, _ABitOfEverything_OneofUnmarshaler, _ABitOfEverything_OneofSizer, []interface{}{ - (*ABitOfEverything_OneofEmpty)(nil), - (*ABitOfEverything_OneofString)(nil), + (*ABitOfEverything_OneofValueString)(nil), + (*ABitOfEverything_OneofValueNested)(nil), } } @@ -344,14 +344,14 @@ func _ABitOfEverything_OneofMarshaler(msg proto.Message, b *proto.Buffer) error m := msg.(*ABitOfEverything) // oneof_value switch x := m.OneofValue.(type) { - case *ABitOfEverything_OneofEmpty: - b.EncodeVarint(20<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.OneofEmpty); err != nil { + case *ABitOfEverything_OneofValueString: + b.EncodeVarint(21<<3 | proto.WireBytes) + b.EncodeStringBytes(x.OneofValueString) + case *ABitOfEverything_OneofValueNested: + b.EncodeVarint(30<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.OneofValueNested); err != nil { return err } - case *ABitOfEverything_OneofString: - b.EncodeVarint(21<<3 | proto.WireBytes) - b.EncodeStringBytes(x.OneofString) case nil: default: return fmt.Errorf("ABitOfEverything.OneofValue has unexpected type %T", x) @@ -362,20 +362,20 @@ func _ABitOfEverything_OneofMarshaler(msg proto.Message, b *proto.Buffer) error func _ABitOfEverything_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { m := msg.(*ABitOfEverything) switch tag { - case 20: // oneof_value.oneof_empty + case 21: // oneof_value.oneof_value_string if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(google_protobuf1.Empty) - err := b.DecodeMessage(msg) - m.OneofValue = &ABitOfEverything_OneofEmpty{msg} + x, err := b.DecodeStringBytes() + m.OneofValue = &ABitOfEverything_OneofValueString{x} return true, err - case 21: // oneof_value.oneof_string + case 30: // oneof_value.oneof_value_nested if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - x, err := b.DecodeStringBytes() - m.OneofValue = &ABitOfEverything_OneofString{x} + msg := new(ABitOfEverything_Nested) + err := b.DecodeMessage(msg) + m.OneofValue = &ABitOfEverything_OneofValueNested{msg} return true, err default: return false, nil @@ -386,15 +386,15 @@ func _ABitOfEverything_OneofSizer(msg proto.Message) (n int) { m := msg.(*ABitOfEverything) // oneof_value switch x := m.OneofValue.(type) { - case *ABitOfEverything_OneofEmpty: - s := proto.Size(x.OneofEmpty) - n += proto.SizeVarint(20<<3 | proto.WireBytes) + case *ABitOfEverything_OneofValueString: + n += proto.SizeVarint(21<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(len(x.OneofValueString))) + n += len(x.OneofValueString) + case *ABitOfEverything_OneofValueNested: + s := proto.Size(x.OneofValueNested) + n += proto.SizeVarint(30<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s - case *ABitOfEverything_OneofString: - n += proto.SizeVarint(21<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.OneofString))) - n += len(x.OneofString) case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) @@ -403,11 +403,17 @@ func _ABitOfEverything_OneofSizer(msg proto.Message) (n int) { } // Nested is nested type. +// NEXT ID: 7 type ABitOfEverything_Nested struct { // name is nested field. - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Amount uint32 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"` - Ok ABitOfEverything_Nested_DeepEnum `protobuf:"varint,3,opt,name=ok,enum=grpc.gateway.examples.examplepb.ABitOfEverything_Nested_DeepEnum" json:"ok,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Amount uint32 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"` + Ok ABitOfEverything_Nested_DeepEnum `protobuf:"varint,3,opt,name=ok,enum=grpc.gateway.examples.examplepb.ABitOfEverything_Nested_DeepEnum" json:"ok,omitempty"` + DeeperNestedValue *grpc_gateway_examples_sub.StringMessage `protobuf:"bytes,4,opt,name=deeper_nested_value,json=deeperNestedValue" json:"deeper_nested_value,omitempty"` + // Types that are valid to be assigned to OneofValue: + // *ABitOfEverything_Nested_OneofValueDeeperNested + // *ABitOfEverything_Nested_OneofValueTerminal + OneofValue isABitOfEverything_Nested_OneofValue `protobuf_oneof:"oneof_value"` } func (m *ABitOfEverything_Nested) Reset() { *m = ABitOfEverything_Nested{} } @@ -415,6 +421,27 @@ func (m *ABitOfEverything_Nested) String() string { return proto.Comp func (*ABitOfEverything_Nested) ProtoMessage() {} func (*ABitOfEverything_Nested) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0, 0} } +type isABitOfEverything_Nested_OneofValue interface { + isABitOfEverything_Nested_OneofValue() +} + +type ABitOfEverything_Nested_OneofValueDeeperNested struct { + OneofValueDeeperNested *grpc_gateway_examples_sub.StringMessage `protobuf:"bytes,15,opt,name=oneof_value_deeper_nested,json=oneofValueDeeperNested,oneof"` +} +type ABitOfEverything_Nested_OneofValueTerminal struct { + OneofValueTerminal string `protobuf:"bytes,16,opt,name=oneof_value_terminal,json=oneofValueTerminal,oneof"` +} + +func (*ABitOfEverything_Nested_OneofValueDeeperNested) isABitOfEverything_Nested_OneofValue() {} +func (*ABitOfEverything_Nested_OneofValueTerminal) isABitOfEverything_Nested_OneofValue() {} + +func (m *ABitOfEverything_Nested) GetOneofValue() isABitOfEverything_Nested_OneofValue { + if m != nil { + return m.OneofValue + } + return nil +} + func (m *ABitOfEverything_Nested) GetName() string { if m != nil { return m.Name @@ -436,6 +463,97 @@ func (m *ABitOfEverything_Nested) GetOk() ABitOfEverything_Nested_DeepEnum { return ABitOfEverything_Nested_FALSE } +func (m *ABitOfEverything_Nested) GetDeeperNestedValue() *grpc_gateway_examples_sub.StringMessage { + if m != nil { + return m.DeeperNestedValue + } + return nil +} + +func (m *ABitOfEverything_Nested) GetOneofValueDeeperNested() *grpc_gateway_examples_sub.StringMessage { + if x, ok := m.GetOneofValue().(*ABitOfEverything_Nested_OneofValueDeeperNested); ok { + return x.OneofValueDeeperNested + } + return nil +} + +func (m *ABitOfEverything_Nested) GetOneofValueTerminal() string { + if x, ok := m.GetOneofValue().(*ABitOfEverything_Nested_OneofValueTerminal); ok { + return x.OneofValueTerminal + } + return "" +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*ABitOfEverything_Nested) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _ABitOfEverything_Nested_OneofMarshaler, _ABitOfEverything_Nested_OneofUnmarshaler, _ABitOfEverything_Nested_OneofSizer, []interface{}{ + (*ABitOfEverything_Nested_OneofValueDeeperNested)(nil), + (*ABitOfEverything_Nested_OneofValueTerminal)(nil), + } +} + +func _ABitOfEverything_Nested_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*ABitOfEverything_Nested) + // oneof_value + switch x := m.OneofValue.(type) { + case *ABitOfEverything_Nested_OneofValueDeeperNested: + b.EncodeVarint(15<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.OneofValueDeeperNested); err != nil { + return err + } + case *ABitOfEverything_Nested_OneofValueTerminal: + b.EncodeVarint(16<<3 | proto.WireBytes) + b.EncodeStringBytes(x.OneofValueTerminal) + case nil: + default: + return fmt.Errorf("ABitOfEverything_Nested.OneofValue has unexpected type %T", x) + } + return nil +} + +func _ABitOfEverything_Nested_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*ABitOfEverything_Nested) + switch tag { + case 15: // oneof_value.oneof_value_deeper_nested + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(grpc_gateway_examples_sub.StringMessage) + err := b.DecodeMessage(msg) + m.OneofValue = &ABitOfEverything_Nested_OneofValueDeeperNested{msg} + return true, err + case 16: // oneof_value.oneof_value_terminal + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeStringBytes() + m.OneofValue = &ABitOfEverything_Nested_OneofValueTerminal{x} + return true, err + default: + return false, nil + } +} + +func _ABitOfEverything_Nested_OneofSizer(msg proto.Message) (n int) { + m := msg.(*ABitOfEverything_Nested) + // oneof_value + switch x := m.OneofValue.(type) { + case *ABitOfEverything_Nested_OneofValueDeeperNested: + s := proto.Size(x.OneofValueDeeperNested) + n += proto.SizeVarint(15<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case *ABitOfEverything_Nested_OneofValueTerminal: + n += proto.SizeVarint(16<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(len(x.OneofValueTerminal))) + n += len(x.OneofValueTerminal) + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + type Body struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` } @@ -1098,132 +1216,144 @@ var _AnotherServiceWithNoBindings_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/proto/examplepb/a_bit_of_everything.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 2019 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0xf7, 0x48, 0xb2, 0x22, 0x3d, 0xf9, 0x43, 0x1e, 0xe7, 0xc3, 0x51, 0x9c, 0xf5, 0x44, 0xc9, - 0xb6, 0x8c, 0x37, 0x22, 0x37, 0xca, 0xa2, 0xd8, 0x08, 0x68, 0xb7, 0xb2, 0xad, 0x4d, 0x82, 0x6c, - 0x9c, 0x84, 0xd9, 0x4d, 0x83, 0x34, 0x5b, 0x83, 0x22, 0x47, 0x12, 0x13, 0x91, 0xc3, 0x92, 0x43, - 0x27, 0xaa, 0xeb, 0x16, 0xed, 0x02, 0x2d, 0xf6, 0x54, 0xc0, 0xbd, 0xef, 0xa5, 0x40, 0xd1, 0x4b, - 0x0f, 0x3d, 0xf4, 0x54, 0xa0, 0x3d, 0xf6, 0xd0, 0x63, 0x81, 0xde, 0x0b, 0xf4, 0xd4, 0x63, 0xff, - 0x82, 0x62, 0x86, 0xa4, 0x42, 0xc9, 0x16, 0x1c, 0x39, 0x8b, 0xbd, 0x24, 0x9c, 0x99, 0xdf, 0x7b, - 0xef, 0xf7, 0xde, 0xbc, 0xf7, 0xe6, 0xc9, 0x50, 0xa7, 0xaf, 0x0c, 0xc7, 0xeb, 0xd3, 0x40, 0xf3, - 0x7c, 0xc6, 0x99, 0x16, 0x2f, 0xbd, 0xb6, 0x66, 0xec, 0xb4, 0x6d, 0xbe, 0xc3, 0x3a, 0x3b, 0x74, - 0x97, 0xfa, 0x03, 0xde, 0xb3, 0xdd, 0xae, 0x2a, 0x31, 0x78, 0xad, 0xeb, 0x7b, 0xa6, 0xda, 0x35, - 0x38, 0x7d, 0x69, 0x0c, 0xd4, 0x44, 0x81, 0x3a, 0x14, 0xad, 0xac, 0x76, 0x19, 0xeb, 0xf6, 0xa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4, 0x98, 0x36, 0x25, 0x9e, 0x16, 0x87, 0xfd, 0xa5, - 0x9d, 0x97, 0x59, 0x79, 0xe3, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0xd8, 0x68, 0xe8, 0x2d, - 0x17, 0x00, 0x00, + // 2211 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4d, 0x6c, 0xdb, 0xc8, + 0x15, 0x36, 0x25, 0x59, 0xb1, 0x9e, 0xff, 0xe4, 0x71, 0xe2, 0xd8, 0x8a, 0x13, 0x4f, 0x98, 0x6c, + 0xab, 0x78, 0x63, 0x71, 0xa3, 0x2c, 0x8a, 0x44, 0xc5, 0xb6, 0x95, 0x6d, 0x6d, 0x12, 0x64, 0xe3, + 0x24, 0x4c, 0x36, 0x1b, 0xb8, 0xd9, 0x1a, 0x94, 0x38, 0x92, 0x98, 0x88, 0x1c, 0x2e, 0x39, 0x74, + 0xac, 0xba, 0x6e, 0xd1, 0x2e, 0xd0, 0x62, 0x4f, 0x05, 0x5c, 0xa0, 0xe8, 0xa9, 0x3d, 0xf6, 0xd2, + 0x5b, 0x2f, 0x05, 0xf6, 0x50, 0xa0, 0x97, 0x1e, 0x7a, 0x2c, 0xd0, 0x7b, 0x81, 0x9e, 0x7a, 0xec, + 0xb9, 0x87, 0x62, 0x86, 0x23, 0x99, 0xd4, 0xcf, 0xca, 0x4a, 0x8a, 0xbd, 0x48, 0x9c, 0x99, 0xef, + 0x7d, 0xef, 0x67, 0xe6, 0xbd, 0x79, 0x24, 0x14, 0xc9, 0x81, 0x61, 0xbb, 0x2d, 0xe2, 0x6b, 0xae, + 0x47, 0x19, 0xd5, 0xe4, 0xd0, 0xad, 0x6a, 0xc6, 0x5e, 0xd5, 0x62, 0x7b, 0xb4, 0xbe, 0x47, 0xf6, + 0x89, 0xd7, 0x66, 0x4d, 0xcb, 0x69, 0x14, 0x04, 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+ 0x7a, 0x8b, 0x1a, 0x6c, 0x6f, 0xdf, 0x68, 0x05, 0x64, 0x39, 0x89, 0x95, 0x7c, 0x42, 0x07, 0x31, + 0xf5, 0x8c, 0xcf, 0xa0, 0xcb, 0x30, 0x63, 0xd2, 0xa0, 0xda, 0x22, 0x12, 0x91, 0xc2, 0x4a, 0x5e, + 0xd1, 0xa7, 0xc3, 0xb9, 0x10, 0xb2, 0x06, 0xd3, 0x96, 0xc3, 0xbe, 0xf5, 0xbe, 0x44, 0x4c, 0x62, + 0x25, 0x9f, 0xd4, 0x41, 0x4c, 0x75, 0x39, 0x82, 0x28, 0x22, 0x8d, 0x95, 0x7c, 0x4a, 0x9f, 0x0e, + 0x22, 0x90, 0x90, 0xe3, 0x66, 0x51, 0x22, 0xce, 0x60, 0x25, 0x3f, 0x29, 0x38, 0x6e, 0x16, 0x43, + 0xc0, 0x15, 0x98, 0xad, 0x5b, 0x07, 0xc4, 0xec, 0x92, 0x4c, 0x61, 0x25, 0x9f, 0xd6, 0x67, 0xe4, + 0x64, 0x1c, 0xd4, 0xe5, 0xc9, 0x60, 0x25, 0x7f, 0x46, 0x82, 0x3a, 0x4c, 0x17, 0x01, 0xaa, 0x94, + 0xb6, 0x24, 0x02, 0xb0, 0x92, 0x9f, 0xd2, 0x33, 0x7c, 0xa6, 0x6b, 0xac, 0xcf, 0x3c, 0xcb, 0x69, + 0x48, 0xc0, 0xb4, 0x88, 0xff, 0x74, 0x38, 0xd7, 0x35, 0xb6, 0xda, 0x66, 0xc4, 0x97, 0x88, 0x8b, + 0x58, 0xc9, 0xcf, 0xe8, 0x20, 0xa6, 0x62, 0x0e, 0x77, 0xcd, 0x98, 0xc5, 0x4a, 0x7e, 0x36, 0x74, + 0xb8, 0x63, 0xc5, 0x7d, 0x00, 0xe2, 0x04, 0xb6, 0x04, 0xcc, 0x61, 0x25, 0x3f, 0x57, 0xbc, 0x3e, + 0x72, 0x3b, 0x77, 0x02, 0x9b, 0x78, 0x56, 0xad, 0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, 0xaa, + 0x6b, 0x30, 0x1b, 0x0d, 0xc5, 0x44, 0x6f, 0xcf, 0x5e, 0xbd, 0x36, 0xb4, 0x6b, 0xef, 0x85, 0x7a, + 0xf7, 0xe0, 0xfc, 0x83, 0x93, 0x1c, 0x8a, 0x1e, 0x8d, 0x71, 0x8f, 0xc4, 0x6e, 0xa6, 0x5b, 0x5f, + 0xaa, 0x69, 0x71, 0x2a, 0x6f, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x01, 0x51, 0x23, 0x61, + 0x1b, 0x00, 0x00, } diff --git a/examples/proto/examplepb/a_bit_of_everything.pb.gw.go b/examples/proto/examplepb/a_bit_of_everything.pb.gw.go index f863b09ac72..06564fe1717 100644 --- a/examples/proto/examplepb/a_bit_of_everything.pb.gw.go +++ b/examples/proto/examplepb/a_bit_of_everything.pb.gw.go @@ -32,7 +32,7 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var ( - filter_ABitOfEverythingService_Create_0 = &utilities.DoubleArray{Encoding: map[string]int{"float_value": 0, "double_value": 1, "int64_value": 2, "uint64_value": 3, "int32_value": 4, "fixed64_value": 5, "fixed32_value": 6, "bool_value": 7, "string_value": 8, "uint32_value": 9, "sfixed32_value": 10, "sfixed64_value": 11, "sint32_value": 12, "sint64_value": 13, "nonConventionalNameValue": 14}, Base: []int{1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}} + filter_ABitOfEverythingService_Create_0 = &utilities.DoubleArray{Encoding: map[string]int{"float_value": 0, "double_value": 1, "int64_value": 2, "uint64_value": 3, "int32_value": 4, "fixed64_value": 5, "fixed32_value": 6, "bool_value": 7, "string_value": 8, "uint32_value": 9, "sfixed32_value": 10, "sfixed64_value": 11, "sint32_value": 12, "sint64_value": 13, "oneof_value_string": 14, "nonConventionalNameValue": 15}, Base: []int{1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}} ) func request_ABitOfEverythingService_Create_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -200,6 +200,25 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sint64_value", err) } + val, ok = pathParams["oneof_value_string"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_value_string") + } + + func() *ABitOfEverything_OneofValueString { + msg := &protoReq + oneof := msg.OneofValue + if _, ok := oneof.(*ABitOfEverything_OneofValueString); oneof == nil || !ok { + oneof = new(ABitOfEverything_OneofValueString) + msg.OneofValue = oneof + } + return oneof.(*ABitOfEverything_OneofValueString) + }().OneofValueString, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_value_string", err) + } + val, ok = pathParams["nonConventionalNameValue"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nonConventionalNameValue") @@ -410,10 +429,27 @@ func request_ABitOfEverythingService_Echo_2(ctx context.Context, marshaler runti } +var ( + filter_ABitOfEverythingService_DeepPathEcho_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + func request_ABitOfEverythingService_DeepPathEcho_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ABitOfEverything var metadata runtime.ServerMetadata + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_DeepPathEcho_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_ABitOfEverythingService_DeepPathEcho_1(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -441,6 +477,258 @@ func request_ABitOfEverythingService_DeepPathEcho_0(ctx context.Context, marshal } +func request_ABitOfEverythingService_DeepPathEcho_2(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["single_nested.deeper_nested_value.value"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.deeper_nested_value.value") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.deeper_nested_value.value", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.deeper_nested_value.value", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_ABitOfEverythingService_DeepPathEcho_3(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["oneof_value_string"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_value_string") + } + + func() *ABitOfEverything_OneofValueString { + msg := &protoReq + oneof := msg.OneofValue + if _, ok := oneof.(*ABitOfEverything_OneofValueString); oneof == nil || !ok { + oneof = new(ABitOfEverything_OneofValueString) + msg.OneofValue = oneof + } + return oneof.(*ABitOfEverything_OneofValueString) + }().OneofValueString, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_value_string", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_ABitOfEverythingService_DeepPathEcho_4(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["oneof_value_nested.name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_value_nested.name") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "oneof_value_nested.name", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_value_nested.name", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_ABitOfEverythingService_DeepPathEcho_5(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["oneof_value_nested.deeper_nested_value.value"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_value_nested.deeper_nested_value.value") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "oneof_value_nested.deeper_nested_value.value", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_value_nested.deeper_nested_value.value", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_ABitOfEverythingService_DeepPathEcho_6(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["oneof_value_nested.oneof_value_terminal"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_value_nested.oneof_value_terminal") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "oneof_value_nested.oneof_value_terminal", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_value_nested.oneof_value_terminal", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_ABitOfEverythingService_DeepPathEcho_7(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["oneof_value_nested.oneof_value_deeper_nested.value"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_value_nested.oneof_value_deeper_nested.value") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "oneof_value_nested.oneof_value_deeper_nested.value", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_value_nested.oneof_value_deeper_nested.value", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +var ( + filter_ABitOfEverythingService_DeepPathEcho_8 = &utilities.DoubleArray{Encoding: map[string]int{"oneof_value_string": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_ABitOfEverythingService_DeepPathEcho_8(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&func() *ABitOfEverything_OneofValueString { + msg := &protoReq + oneof := msg.OneofValue + if _, ok := oneof.(*ABitOfEverything_OneofValueString); oneof == nil || !ok { + oneof = new(ABitOfEverything_OneofValueString) + msg.OneofValue = oneof + } + return oneof.(*ABitOfEverything_OneofValueString) + }().OneofValueString); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_DeepPathEcho_8); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +var ( + filter_ABitOfEverythingService_DeepPathEcho_9 = &utilities.DoubleArray{Encoding: map[string]int{"oneof_value_nested": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_ABitOfEverythingService_DeepPathEcho_9(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABitOfEverything + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&func() *ABitOfEverything_OneofValueNested { + msg := &protoReq + oneof := msg.OneofValue + if _, ok := oneof.(*ABitOfEverything_OneofValueNested); oneof == nil || !ok { + oneof = new(ABitOfEverything_OneofValueNested) + msg.OneofValue = oneof + } + return oneof.(*ABitOfEverything_OneofValueNested) + }().OneofValueNested); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_DeepPathEcho_9); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + func request_ABitOfEverythingService_Timeout_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq empty.Empty var metadata runtime.ServerMetadata @@ -858,6 +1146,267 @@ func RegisterABitOfEverythingServiceHandlerClient(ctx context.Context, mux *runt }) + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_2(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_2(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_3(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_3(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_4(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_4(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_5(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_5(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_6(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_6(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_7, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_7(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_7(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_8, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_8(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_8(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ABitOfEverythingService_DeepPathEcho_9, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ABitOfEverythingService_DeepPathEcho_9(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ABitOfEverythingService_DeepPathEcho_9(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_ABitOfEverythingService_Timeout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -978,7 +1527,7 @@ func RegisterABitOfEverythingServiceHandlerClient(ctx context.Context, mux *runt } var ( - pattern_ABitOfEverythingService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 1, 0, 4, 1, 5, 8, 1, 0, 4, 1, 5, 9, 1, 0, 4, 1, 5, 10, 1, 0, 4, 1, 5, 11, 2, 12, 1, 0, 4, 2, 5, 13, 1, 0, 4, 1, 5, 14, 1, 0, 4, 1, 5, 15, 1, 0, 4, 1, 5, 16, 1, 0, 4, 1, 5, 17, 1, 0, 4, 1, 5, 18, 1, 0, 4, 1, 5, 19}, []string{"v1", "example", "a_bit_of_everything", "float_value", "double_value", "int64_value", "separator", "uint64_value", "int32_value", "fixed64_value", "fixed32_value", "bool_value", "strprefix", "string_value", "uint32_value", "sfixed32_value", "sfixed64_value", "sint32_value", "sint64_value", "nonConventionalNameValue"}, "")) + pattern_ABitOfEverythingService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 1, 0, 4, 1, 5, 8, 1, 0, 4, 1, 5, 9, 1, 0, 4, 1, 5, 10, 1, 0, 4, 1, 5, 11, 2, 12, 1, 0, 4, 2, 5, 13, 1, 0, 4, 1, 5, 14, 1, 0, 4, 1, 5, 15, 1, 0, 4, 1, 5, 16, 1, 0, 4, 1, 5, 17, 1, 0, 4, 1, 5, 18, 1, 0, 4, 1, 5, 19, 1, 0, 4, 1, 5, 20}, []string{"v1", "example", "a_bit_of_everything", "float_value", "double_value", "int64_value", "separator", "uint64_value", "int32_value", "fixed64_value", "fixed32_value", "bool_value", "strprefix", "string_value", "uint32_value", "sfixed32_value", "sfixed64_value", "sint32_value", "sint64_value", "oneof_value_string", "nonConventionalNameValue"}, "")) pattern_ABitOfEverythingService_CreateBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "a_bit_of_everything"}, "")) @@ -996,7 +1545,25 @@ var ( pattern_ABitOfEverythingService_Echo_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "echo"}, "")) - pattern_ABitOfEverythingService_DeepPathEcho_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "single_nested.name"}, "")) + pattern_ABitOfEverythingService_DeepPathEcho_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "a_bit_of_everything;echo"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "single_nested.name"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v2", "example", "single_nested", "deeper_nested_value", "single_nested.deeper_nested_value.value"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 2}, []string{"v2", "example", "oneof_value_string", "echo"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"v2", "example", "oneof_value_nested", "name", "echo", "oneof_value_nested.name"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"v2", "example", "oneof_value_nested", "deeper_nested_value", "value", "echo", "oneof_value_nested.deeper_nested_value.value"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"v2", "example", "oneof_value_nested", "oneof_value_terminal", "echo", "oneof_value_nested.oneof_value_terminal"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_7 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"v2", "example", "oneof_value_nested", "oneof_value_deeper_nested", "value", "echo", "oneof_value_nested.oneof_value_deeper_nested.value"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_8 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v2", "example", "oneof_value_string", "echo"}, "")) + + pattern_ABitOfEverythingService_DeepPathEcho_9 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v2", "example", "oneof_value_nested", "echo"}, "")) pattern_ABitOfEverythingService_Timeout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "timeout"}, "")) @@ -1028,6 +1595,24 @@ var ( forward_ABitOfEverythingService_DeepPathEcho_0 = runtime.ForwardResponseMessage + forward_ABitOfEverythingService_DeepPathEcho_1 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_2 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_3 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_4 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_5 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_6 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_7 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_8 = runtime.ForwardResponseMessage + + forward_ABitOfEverythingService_DeepPathEcho_9 = runtime.ForwardResponseMessage + forward_ABitOfEverythingService_Timeout_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_ErrorWithDetails_0 = runtime.ForwardResponseMessage diff --git a/examples/proto/examplepb/a_bit_of_everything.proto b/examples/proto/examplepb/a_bit_of_everything.proto index 6eaa7d8fd9a..b22b2c9a8db 100644 --- a/examples/proto/examplepb/a_bit_of_everything.proto +++ b/examples/proto/examplepb/a_bit_of_everything.proto @@ -98,7 +98,7 @@ option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { // Intentionaly complicated message type to cover much features of Protobuf. -// NEXT ID: 30 +// NEXT ID: 31 message ABitOfEverything { option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = { external_docs: { @@ -108,6 +108,7 @@ message ABitOfEverything { }; // Nested is nested type. + // NEXT ID: 7 message Nested { // name is nested field. string name = 1; @@ -120,6 +121,12 @@ message ABitOfEverything { TRUE = 1; } DeepEnum ok = 3; + + sub.StringMessage deeper_nested_value = 4; + oneof oneof_value { + sub.StringMessage oneof_value_deeper_nested= 15; + string oneof_value_terminal = 16; + } } Nested single_nested = 25; @@ -143,8 +150,9 @@ message ABitOfEverything { sint64 sint64_value = 18; repeated string repeated_string_value = 19; oneof oneof_value { - google.protobuf.Empty oneof_empty = 20; - string oneof_string = 21; + /* tag 20 is reserved */ + string oneof_value_string = 21; + Nested oneof_value_nested = 30; } map map_value = 22; @@ -189,18 +197,26 @@ service ABitOfEverythingService { } }; + // Covers all types of fields in path parameters. + rpc Create(ABitOfEverything) returns (ABitOfEverything) { // TODO add enum_value 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}" + 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}/{oneof_value_string}/{nonConventionalNameValue}" }; } + + // Covers all types of fields in the request body. + rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything" body: "*" }; } + + // Covers other request methods + rpc Lookup(sub2.IdMessage) returns (ABitOfEverything) { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/{uuid}" @@ -232,6 +248,9 @@ service ABitOfEverythingService { } }; } + + // Covers all types of fields in query parameters + rpc GetQuery(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/query/{uuid}" @@ -244,6 +263,7 @@ service ABitOfEverythingService { } }; } + // Echo allows posting a StringMessage value. // // It also exposes multiple bindings. @@ -252,8 +272,16 @@ service ABitOfEverythingService { // description exposes documentation correctly on all paths // defined as additional_bindings in the proto. rpc Echo(grpc.gateway.examples.sub.StringMessage) returns (grpc.gateway.examples.sub.StringMessage) { + // Covers: + // 1. additional_bindings feature + // 2. non-'*' body + // 3. messages defined in another package than the service option (google.api.http) = { get: "/v1/example/a_bit_of_everything/echo/{value}" + + // additonal bindings can have different ways of parameter bindings + // and HTTP methods. + additional_bindings { post: "/v2/example/echo" body: "value" @@ -275,8 +303,50 @@ service ABitOfEverythingService { } rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { - post: "/v1/example/a_bit_of_everything/{single_nested.name}" - body: "*" + post: "/v1/example/a_bit_of_everything;echo" + + // Covers 2nd or even deeper level fields in path parameters. + additional_bindings { + post: "/v1/example/a_bit_of_everything/{single_nested.name}" + body: "*" + } + additional_bindings { + post: "/v2/example/single_nested/deeper_nested_value/{single_nested.deeper_nested_value.value}" + body: "*" + } + + // deeper oneof fields in path parameters. + additional_bindings { + post: "/v2/example/oneof_value_string/echo/{oneof_value_string}" + body: "*" + } + additional_bindings { + post: "/v2/example/oneof_value_nested/name/echo/{oneof_value_nested.name}" + body: "*" + } + additional_bindings { + post: "/v2/example/oneof_value_nested/deeper_nested_value/value/echo/{oneof_value_nested.deeper_nested_value.value}" + body: "*" + } + additional_bindings { + post: "/v2/example/oneof_value_nested/oneof_value_terminal/echo/{oneof_value_nested.oneof_value_terminal}" + body: "*" + } + additional_bindings { + post: "/v2/example/oneof_value_nested/oneof_value_deeper_nested/value/echo/{oneof_value_nested.oneof_value_deeper_nested.value}" + body: "*" + } + + additional_bindings { + post: "/v2/example/oneof_value_string/echo" + // a oneof option in body + body: "oneof_value_string" + } + additional_bindings { + post: "/v2/example/oneof_value_nested/echo" + // a oneof option in body + body: "oneof_value_nested" + } }; } rpc NoBindings(google.protobuf.Duration) returns (google.protobuf.Empty) {} diff --git a/examples/proto/examplepb/a_bit_of_everything.swagger.json b/examples/proto/examplepb/a_bit_of_everything.swagger.json index aa7f2479021..7a797bdeeca 100644 --- a/examples/proto/examplepb/a_bit_of_everything.swagger.json +++ b/examples/proto/examplepb/a_bit_of_everything.swagger.json @@ -124,6 +124,24 @@ ], "default": "FALSE" }, + { + "name": "single_nested.deeper_nested_value.value", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "single_nested.oneof_value_deeper_nested.value", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "single_nested.oneof_value_terminal", + "in": "query", + "required": false, + "type": "string" + }, { "name": "float_value", "in": "query", @@ -250,7 +268,52 @@ } }, { - "name": "oneof_string", + "name": "oneof_value_string", + "description": "tag 20 is reserved.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "oneof_value_nested.name", + "description": "name is nested field.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "oneof_value_nested.amount", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "oneof_value_nested.ok", + "description": " - FALSE: FALSE is false.\n - TRUE: TRUE is true.", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "FALSE", + "TRUE" + ], + "default": "FALSE" + }, + { + "name": "oneof_value_nested.deeper_nested_value.value", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "oneof_value_nested.oneof_value_deeper_nested.value", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "oneof_value_nested.oneof_value_terminal", "in": "query", "required": false, "type": "string" @@ -293,7 +356,7 @@ } } }, - "/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}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}": { + "/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}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{oneof_value_string}/{nonConventionalNameValue}": { "post": { "operationId": "Create", "responses": { @@ -402,6 +465,12 @@ "type": "string", "format": "int64" }, + { + "name": "oneof_value_string", + "in": "path", + "required": true, + "type": "string" + }, { "name": "nonConventionalNameValue", "in": "path", @@ -416,7 +485,7 @@ }, "/v1/example/a_bit_of_everything/{single_nested.name}": { "post": { - "operationId": "DeepPathEcho", + "operationId": "DeepPathEcho2", "responses": { "200": { "description": "", @@ -531,6 +600,22 @@ ] } }, + "/v1/example/a_bit_of_everything;echo": { + "post": { + "operationId": "DeepPathEcho", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "tags": [ + "ABitOfEverythingService" + ] + } + }, "/v2/example/echo": { "get": { "summary": "Summary: Echo rpc", @@ -625,6 +710,218 @@ ] } }, + "/v2/example/oneof_value_nested/deeper_nested_value/value/echo/{oneof_value_nested.deeper_nested_value.value}": { + "post": { + "operationId": "DeepPathEcho6", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "oneof_value_nested.deeper_nested_value.value", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, + "/v2/example/oneof_value_nested/echo": { + "post": { + "operationId": "DeepPathEcho10", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ABitOfEverythingNested" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, + "/v2/example/oneof_value_nested/name/echo/{oneof_value_nested.name}": { + "post": { + "operationId": "DeepPathEcho5", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "oneof_value_nested.name", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, + "/v2/example/oneof_value_nested/oneof_value_deeper_nested/value/echo/{oneof_value_nested.oneof_value_deeper_nested.value}": { + "post": { + "operationId": "DeepPathEcho8", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "oneof_value_nested.oneof_value_deeper_nested.value", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, + "/v2/example/oneof_value_nested/oneof_value_terminal/echo/{oneof_value_nested.oneof_value_terminal}": { + "post": { + "operationId": "DeepPathEcho7", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "oneof_value_nested.oneof_value_terminal", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, + "/v2/example/oneof_value_string/echo": { + "post": { + "operationId": "DeepPathEcho9", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, + "/v2/example/oneof_value_string/echo/{oneof_value_string}": { + "post": { + "operationId": "DeepPathEcho4", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "oneof_value_string", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, "/v2/example/postwithemptybody/{name}": { "post": { "operationId": "PostWithEmptyBody", @@ -657,6 +954,38 @@ ] } }, + "/v2/example/single_nested/deeper_nested_value/{single_nested.deeper_nested_value.value}": { + "post": { + "operationId": "DeepPathEcho3", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + }, + "parameters": [ + { + "name": "single_nested.deeper_nested_value.value", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/examplepbABitOfEverything" + } + } + ], + "tags": [ + "ABitOfEverythingService" + ] + } + }, "/v2/example/timeout": { "get": { "operationId": "Timeout", @@ -720,9 +1049,18 @@ }, "ok": { "$ref": "#/definitions/NestedDeepEnum" + }, + "deeper_nested_value": { + "$ref": "#/definitions/subStringMessage" + }, + "oneof_value_deeper_nested": { + "$ref": "#/definitions/subStringMessage" + }, + "oneof_value_terminal": { + "type": "string" } }, - "description": "Nested is nested type." + "title": "Nested is nested type.\nNEXT ID: 7" }, "NestedDeepEnum": { "type": "string", @@ -816,11 +1154,12 @@ "type": "string" } }, - "oneof_empty": { - "$ref": "#/definitions/protobufEmpty" + "oneof_value_string": { + "type": "string", + "title": "tag 20 is reserved" }, - "oneof_string": { - "type": "string" + "oneof_value_nested": { + "$ref": "#/definitions/ABitOfEverythingNested" }, "map_value": { "type": "object", @@ -855,7 +1194,7 @@ "title": "repeated enum value. it is comma-separated in query" } }, - "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 30", + "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 31", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" diff --git a/examples/proto/examplepb/echo_service.pb.go b/examples/proto/examplepb/echo_service.pb.go index f200e4881ac..2e61c94ed01 100644 --- a/examples/proto/examplepb/echo_service.pb.go +++ b/examples/proto/examplepb/echo_service.pb.go @@ -18,7 +18,6 @@ It is generated from these files: examples/proto/examplepb/unannotated_echo_service.proto It has these top-level messages: - Embedded SimpleMessage ABitOfEverything Body @@ -54,177 +53,17 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package -// Embedded represents a message embedded in SimpleMessage. -type Embedded struct { - // Types that are valid to be assigned to Mark: - // *Embedded_Progress - // *Embedded_Note - Mark isEmbedded_Mark `protobuf_oneof:"mark"` -} - -func (m *Embedded) Reset() { *m = Embedded{} } -func (m *Embedded) String() string { return proto.CompactTextString(m) } -func (*Embedded) ProtoMessage() {} -func (*Embedded) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -type isEmbedded_Mark interface { - isEmbedded_Mark() -} - -type Embedded_Progress struct { - Progress int64 `protobuf:"varint,1,opt,name=progress,oneof"` -} -type Embedded_Note struct { - Note string `protobuf:"bytes,2,opt,name=note,oneof"` -} - -func (*Embedded_Progress) isEmbedded_Mark() {} -func (*Embedded_Note) isEmbedded_Mark() {} - -func (m *Embedded) GetMark() isEmbedded_Mark { - if m != nil { - return m.Mark - } - return nil -} - -func (m *Embedded) GetProgress() int64 { - if x, ok := m.GetMark().(*Embedded_Progress); ok { - return x.Progress - } - return 0 -} - -func (m *Embedded) GetNote() string { - if x, ok := m.GetMark().(*Embedded_Note); ok { - return x.Note - } - return "" -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Embedded) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Embedded_OneofMarshaler, _Embedded_OneofUnmarshaler, _Embedded_OneofSizer, []interface{}{ - (*Embedded_Progress)(nil), - (*Embedded_Note)(nil), - } -} - -func _Embedded_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Embedded) - // mark - switch x := m.Mark.(type) { - case *Embedded_Progress: - b.EncodeVarint(1<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.Progress)) - case *Embedded_Note: - b.EncodeVarint(2<<3 | proto.WireBytes) - b.EncodeStringBytes(x.Note) - case nil: - default: - return fmt.Errorf("Embedded.Mark has unexpected type %T", x) - } - return nil -} - -func _Embedded_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Embedded) - switch tag { - case 1: // mark.progress - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Mark = &Embedded_Progress{int64(x)} - return true, err - case 2: // mark.note - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Mark = &Embedded_Note{x} - return true, err - default: - return false, nil - } -} - -func _Embedded_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Embedded) - // mark - switch x := m.Mark.(type) { - case *Embedded_Progress: - n += proto.SizeVarint(1<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.Progress)) - case *Embedded_Note: - n += proto.SizeVarint(2<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.Note))) - n += len(x.Note) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - // SimpleMessage represents a simple message sent to the Echo service. type SimpleMessage struct { // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=num" json:"num,omitempty"` - // Types that are valid to be assigned to Code: - // *SimpleMessage_LineNum - // *SimpleMessage_Lang - Code isSimpleMessage_Code `protobuf_oneof:"code"` - Status *Embedded `protobuf:"bytes,5,opt,name=status" json:"status,omitempty"` - // Types that are valid to be assigned to Ext: - // *SimpleMessage_En - // *SimpleMessage_No - Ext isSimpleMessage_Ext `protobuf_oneof:"ext"` } func (m *SimpleMessage) Reset() { *m = SimpleMessage{} } func (m *SimpleMessage) String() string { return proto.CompactTextString(m) } func (*SimpleMessage) ProtoMessage() {} -func (*SimpleMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -type isSimpleMessage_Code interface { - isSimpleMessage_Code() -} -type isSimpleMessage_Ext interface { - isSimpleMessage_Ext() -} - -type SimpleMessage_LineNum struct { - LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,oneof"` -} -type SimpleMessage_Lang struct { - Lang string `protobuf:"bytes,4,opt,name=lang,oneof"` -} -type SimpleMessage_En struct { - En int64 `protobuf:"varint,6,opt,name=en,oneof"` -} -type SimpleMessage_No struct { - No *Embedded `protobuf:"bytes,7,opt,name=no,oneof"` -} - -func (*SimpleMessage_LineNum) isSimpleMessage_Code() {} -func (*SimpleMessage_Lang) isSimpleMessage_Code() {} -func (*SimpleMessage_En) isSimpleMessage_Ext() {} -func (*SimpleMessage_No) isSimpleMessage_Ext() {} - -func (m *SimpleMessage) GetCode() isSimpleMessage_Code { - if m != nil { - return m.Code - } - return nil -} -func (m *SimpleMessage) GetExt() isSimpleMessage_Ext { - if m != nil { - return m.Ext - } - return nil -} +func (*SimpleMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (m *SimpleMessage) GetId() string { if m != nil { @@ -240,153 +79,7 @@ func (m *SimpleMessage) GetNum() int64 { return 0 } -func (m *SimpleMessage) GetLineNum() int64 { - if x, ok := m.GetCode().(*SimpleMessage_LineNum); ok { - return x.LineNum - } - return 0 -} - -func (m *SimpleMessage) GetLang() string { - if x, ok := m.GetCode().(*SimpleMessage_Lang); ok { - return x.Lang - } - return "" -} - -func (m *SimpleMessage) GetStatus() *Embedded { - if m != nil { - return m.Status - } - return nil -} - -func (m *SimpleMessage) GetEn() int64 { - if x, ok := m.GetExt().(*SimpleMessage_En); ok { - return x.En - } - return 0 -} - -func (m *SimpleMessage) GetNo() *Embedded { - if x, ok := m.GetExt().(*SimpleMessage_No); ok { - return x.No - } - return nil -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*SimpleMessage) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _SimpleMessage_OneofMarshaler, _SimpleMessage_OneofUnmarshaler, _SimpleMessage_OneofSizer, []interface{}{ - (*SimpleMessage_LineNum)(nil), - (*SimpleMessage_Lang)(nil), - (*SimpleMessage_En)(nil), - (*SimpleMessage_No)(nil), - } -} - -func _SimpleMessage_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*SimpleMessage) - // code - switch x := m.Code.(type) { - case *SimpleMessage_LineNum: - b.EncodeVarint(3<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.LineNum)) - case *SimpleMessage_Lang: - b.EncodeVarint(4<<3 | proto.WireBytes) - b.EncodeStringBytes(x.Lang) - case nil: - default: - return fmt.Errorf("SimpleMessage.Code has unexpected type %T", x) - } - // ext - switch x := m.Ext.(type) { - case *SimpleMessage_En: - b.EncodeVarint(6<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.En)) - case *SimpleMessage_No: - b.EncodeVarint(7<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.No); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("SimpleMessage.Ext has unexpected type %T", x) - } - return nil -} - -func _SimpleMessage_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*SimpleMessage) - switch tag { - case 3: // code.line_num - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Code = &SimpleMessage_LineNum{int64(x)} - return true, err - case 4: // code.lang - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Code = &SimpleMessage_Lang{x} - return true, err - case 6: // ext.en - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Ext = &SimpleMessage_En{int64(x)} - return true, err - case 7: // ext.no - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Embedded) - err := b.DecodeMessage(msg) - m.Ext = &SimpleMessage_No{msg} - return true, err - default: - return false, nil - } -} - -func _SimpleMessage_OneofSizer(msg proto.Message) (n int) { - m := msg.(*SimpleMessage) - // code - switch x := m.Code.(type) { - case *SimpleMessage_LineNum: - n += proto.SizeVarint(3<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.LineNum)) - case *SimpleMessage_Lang: - n += proto.SizeVarint(4<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.Lang))) - n += len(x.Lang) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - // ext - switch x := m.Ext.(type) { - case *SimpleMessage_En: - n += proto.SizeVarint(6<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.En)) - case *SimpleMessage_No: - s := proto.Size(x.No) - n += proto.SizeVarint(7<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { - proto.RegisterType((*Embedded)(nil), "grpc.gateway.examples.examplepb.Embedded") proto.RegisterType((*SimpleMessage)(nil), "grpc.gateway.examples.examplepb.SimpleMessage") } @@ -543,35 +236,23 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/proto/examplepb/echo_service.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 470 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x3f, 0x6f, 0xd3, 0x40, - 0x14, 0xef, 0xd9, 0x6e, 0x9a, 0xbc, 0x08, 0x54, 0x9d, 0x40, 0x98, 0xb4, 0xa8, 0x91, 0xc5, 0x10, - 0x8a, 0xe4, 0x53, 0xc2, 0x06, 0x13, 0x11, 0x45, 0x5d, 0x60, 0x70, 0xb7, 0x2c, 0xd1, 0xc5, 0xf7, - 0xe4, 0x5a, 0xd8, 0x77, 0x96, 0x7d, 0x29, 0x8d, 0xac, 0x2c, 0x48, 0x6c, 0x30, 0xb1, 0xf3, 0x11, - 0xd8, 0xf8, 0x18, 0x4c, 0x7c, 0x05, 0x3e, 0x08, 0xba, 0x4b, 0x1c, 0x09, 0x5a, 0xb5, 0xea, 0x90, - 0xcd, 0xef, 0xcf, 0xef, 0xfd, 0x7e, 0xf7, 0x7b, 0xcf, 0xf0, 0x1c, 0x2f, 0x79, 0x5e, 0x64, 0x58, - 0xb1, 0xa2, 0x54, 0x5a, 0xb1, 0x75, 0x58, 0xcc, 0x18, 0xc6, 0xe7, 0x6a, 0x5a, 0x61, 0x79, 0x91, - 0xc6, 0x18, 0xda, 0x22, 0x3d, 0x4a, 0xca, 0x22, 0x0e, 0x13, 0xae, 0xf1, 0x23, 0x5f, 0x84, 0x0d, - 0x32, 0xdc, 0x60, 0x7a, 0x87, 0x89, 0x52, 0x49, 0x86, 0x8c, 0x17, 0x29, 0xe3, 0x52, 0x2a, 0xcd, - 0x75, 0xaa, 0x64, 0xb5, 0x82, 0x07, 0x6f, 0xa1, 0x7d, 0x92, 0xcf, 0x50, 0x08, 0x14, 0xf4, 0x10, - 0xda, 0x45, 0xa9, 0x92, 0x12, 0xab, 0xca,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86, 0xcd, 0xcd, 0xd8, 0x8b, 0x61, - 0x75, 0x2a, 0x96, 0x93, 0x27, 0xf4, 0xe0, 0xda, 0x02, 0xab, 0xe5, 0x3c, 0x5f, 0x4e, 0x9e, 0xd2, - 0xe0, 0x86, 0x32, 0xab, 0x8d, 0xfd, 0xcb, 0xc9, 0x90, 0xb2, 0xff, 0xbb, 0x86, 0xeb, 0xb6, 0x66, - 0x95, 0x4b, 0x56, 0xaf, 0x9c, 0x0e, 0xcd, 0x81, 0x5c, 0xcb, 0x3b, 0x62, 0xb5, 0x54, 0xab, 0x32, - 0xfd, 0x42, 0xa0, 0x6d, 0x0c, 0x1a, 0x2b, 0xb1, 0xd8, 0xba, 0x49, 0x7d, 0xeb, 0x51, 0xef, 0xaa, - 0x45, 0xd3, 0x99, 0x12, 0x8b, 0x97, 0xe4, 0x98, 0x7e, 0x25, 0x00, 0x46, 0xce, 0x1b, 0xcc, 0x50, - 0xe3, 0xd6, 0x05, 0x1d, 0x59, 0x41, 0x8f, 0x8f, 0x1f, 0x5d, 0x11, 0x24, 0xac, 0x80, 0x71, 0x77, - 0xd2, 0xd9, 0x60, 0x67, 0x2d, 0xfb, 0xcf, 0xbe, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xe9, 0xdb, - 0x6f, 0x39, 0x21, 0x04, 0x00, 0x00, + // 288 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xad, 0x48, 0xcc, + 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x87, 0x72, 0x0b, 0x92, 0xf4, + 0x53, 0x93, 0x33, 0xf2, 0xe3, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0xc0, 0x92, 0x42, + 0xf2, 0xe9, 0x45, 0x05, 0xc9, 0x7a, 0xe9, 0x89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x5c, + 0x20, 0xe7, 0xb8, 0xa4, 0xe6, 0xa4, 0x96, 0xa4, 0xd2, 0xdc, 0x41, 0xf2, 0x60, 0x07, 0x49, 0x6a, + 0x89, 0x63, 0x38, 0x28, 0x05, 0xec, 0x00, 0x27, 0xee, 0x28, 0x4e, 0xb8, 0xde, 0x24, 0x36, 0x70, + 0xe2, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x46, 0x53, 0x05, 0xe1, 0x8a, 0x02, 0x00, 0x00, } diff --git a/examples/proto/examplepb/echo_service.pb.gw.go b/examples/proto/examplepb/echo_service.pb.gw.go index 844ef1418ad..c281543bedb 100644 --- a/examples/proto/examplepb/echo_service.pb.gw.go +++ b/examples/proto/examplepb/echo_service.pb.gw.go @@ -63,10 +63,6 @@ func request_EchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler } -var ( - filter_EchoService_Echo_1 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} -) - func request_EchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq SimpleMessage var metadata runtime.ServerMetadata @@ -100,169 +96,6 @@ func request_EchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_EchoService_Echo_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -var ( - filter_EchoService_Echo_2 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1, "lang": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}} -) - -func request_EchoService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SimpleMessage - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - val, ok = pathParams["num"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") - } - - protoReq.Num, err = runtime.Int64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) - } - - val, ok = pathParams["lang"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "lang") - } - - if protoReq.Code == nil { - protoReq.Code = &SimpleMessage_Lang{} - } else if _, ok := protoReq.Code.(*SimpleMessage_Lang); !ok { - return nil, metadata, grpc.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_Lang, but: %t\n", protoReq.Code) - } - protoReq.Code.(*SimpleMessage_Lang).Lang, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "lang", err) - } - - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_EchoService_Echo_2); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -var ( - filter_EchoService_Echo_3 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "line_num": 1, "status": 2, "note": 3}, Base: []int{1, 1, 2, 1, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 4, 2, 3, 5}} -) - -func request_EchoService_Echo_3(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SimpleMessage - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - val, ok = pathParams["line_num"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "line_num") - } - - if protoReq.Code == nil { - protoReq.Code = &SimpleMessage_LineNum{} - } else if _, ok := protoReq.Code.(*SimpleMessage_LineNum); !ok { - return nil, metadata, grpc.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_LineNum, but: %t\n", protoReq.Code) - } - protoReq.Code.(*SimpleMessage_LineNum).LineNum, err = runtime.Int64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "line_num", err) - } - - val, ok = pathParams["status.note"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status.note") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "status.note", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status.note", err) - } - - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_EchoService_Echo_3); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -var ( - filter_EchoService_Echo_4 = &utilities.DoubleArray{Encoding: map[string]int{"no": 0, "note": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} -) - -func request_EchoService_Echo_4(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SimpleMessage - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["no.note"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "no.note") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "no.note", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "no.note", err) - } - - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_EchoService_Echo_4); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -394,93 +227,6 @@ func RegisterEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux }) - mux.Handle("GET", pattern_EchoService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - 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_EchoService_Echo_2(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_EchoService_Echo_2(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_EchoService_Echo_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - 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_EchoService_Echo_3(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_EchoService_Echo_3(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_EchoService_Echo_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - 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_EchoService_Echo_4(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_EchoService_Echo_4(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("POST", pattern_EchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -547,12 +293,6 @@ var ( pattern_EchoService_Echo_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "echo", "id", "num"}, "")) - pattern_EchoService_Echo_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "echo", "id", "num", "lang"}, "")) - - pattern_EchoService_Echo_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "echo1", "id", "line_num", "status.note"}, "")) - - pattern_EchoService_Echo_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo2", "no.note"}, "")) - pattern_EchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_body"}, "")) pattern_EchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_delete"}, "")) @@ -563,12 +303,6 @@ var ( forward_EchoService_Echo_1 = runtime.ForwardResponseMessage - forward_EchoService_Echo_2 = runtime.ForwardResponseMessage - - forward_EchoService_Echo_3 = runtime.ForwardResponseMessage - - forward_EchoService_Echo_4 = runtime.ForwardResponseMessage - forward_EchoService_EchoBody_0 = runtime.ForwardResponseMessage forward_EchoService_EchoDelete_0 = runtime.ForwardResponseMessage diff --git a/examples/proto/examplepb/echo_service.proto b/examples/proto/examplepb/echo_service.proto index 710d0576e45..506917c11c1 100644 --- a/examples/proto/examplepb/echo_service.proto +++ b/examples/proto/examplepb/echo_service.proto @@ -9,28 +9,11 @@ package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; -// Embedded represents a message embedded in SimpleMessage. -message Embedded { - 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; - } } // Echo service responds to incoming echo requests. @@ -45,15 +28,6 @@ service EchoService { 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. diff --git a/examples/proto/examplepb/echo_service.swagger.json b/examples/proto/examplepb/echo_service.swagger.json index c14354ffbce..f76f9289a81 100644 --- a/examples/proto/examplepb/echo_service.swagger.json +++ b/examples/proto/examplepb/echo_service.swagger.json @@ -68,278 +68,6 @@ "required": true, "type": "string", "format": "int64" - }, - { - "name": "line_num", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "lang", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "status.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "status.note", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "en", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.note", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "EchoService" - ] - } - }, - "/v1/example/echo/{id}/{num}/{lang}": { - "get": { - "summary": "Echo method receives a simple message and returns it.", - "description": "The message posted as the id parameter will also be\nreturned.", - "operationId": "Echo3", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/examplepbSimpleMessage" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "num", - "in": "path", - "required": true, - "type": "string", - "format": "int64" - }, - { - "name": "lang", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "line_num", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "status.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "status.note", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "en", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.note", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "EchoService" - ] - } - }, - "/v1/example/echo1/{id}/{line_num}/{status.note}": { - "get": { - "summary": "Echo method receives a simple message and returns it.", - "description": "The message posted as the id parameter will also be\nreturned.", - "operationId": "Echo4", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/examplepbSimpleMessage" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "line_num", - "in": "path", - "required": true, - "type": "string", - "format": "int64" - }, - { - "name": "status.note", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "num", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "lang", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "status.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "en", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - } - ], - "tags": [ - "EchoService" - ] - } - }, - "/v1/example/echo2/{no.note}": { - "get": { - "summary": "Echo method receives a simple message and returns it.", - "description": "The message posted as the id parameter will also be\nreturned.", - "operationId": "Echo5", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/examplepbSimpleMessage" - } - } - }, - "parameters": [ - { - "name": "no.note", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "id", - "description": "Id represents the message identifier.", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "num", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "line_num", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "lang", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "status.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "en", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" } ], "tags": [ @@ -400,52 +128,6 @@ "required": false, "type": "string", "format": "int64" - }, - { - "name": "line_num", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "lang", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "status.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "status.note", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "en", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.progress", - "in": "query", - "required": false, - "type": "string", - "format": "int64" - }, - { - "name": "no.note", - "in": "query", - "required": false, - "type": "string" } ], "tags": [ @@ -455,19 +137,6 @@ } }, "definitions": { - "examplepbEmbedded": { - "type": "object", - "properties": { - "progress": { - "type": "string", - "format": "int64" - }, - "note": { - "type": "string" - } - }, - "description": "Embedded represents a message embedded in SimpleMessage." - }, "examplepbSimpleMessage": { "type": "object", "properties": { @@ -478,23 +147,6 @@ "num": { "type": "string", "format": "int64" - }, - "line_num": { - "type": "string", - "format": "int64" - }, - "lang": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/examplepbEmbedded" - }, - "en": { - "type": "string", - "format": "int64" - }, - "no": { - "$ref": "#/definitions/examplepbEmbedded" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." diff --git a/protoc-gen-grpc-gateway/descriptor/services.go b/protoc-gen-grpc-gateway/descriptor/services.go index c200e57e275..d552da048af 100644 --- a/protoc-gen-grpc-gateway/descriptor/services.go +++ b/protoc-gen-grpc-gateway/descriptor/services.go @@ -235,6 +235,9 @@ func (r *Registry) newBody(meth *Method, path string) (*Body, error) { if err != nil { return nil, err } + if len(fields) > 1 { + return nil, fmt.Errorf("body field must be present at the top-level of request message type") + } return &Body{FieldPath: FieldPath(fields)}, nil } @@ -278,6 +281,7 @@ func (r *Registry) resolveFieldPath(msg *Message, path string) ([]FieldPathCompo return nil, fmt.Errorf("no field %q found in %s", path, root.GetName()) } if f.GetLabel() == descriptor.FieldDescriptorProto_LABEL_REPEATED { + // https://groups.google.com/d/msg/grpc-io/Xqx80hG0D44/yyqfF2gTEFMJ return nil, fmt.Errorf("repeated field not allowed in field path: %s in %s", f.GetName(), path) } result = append(result, FieldPathComponent{Name: c, Target: f}) diff --git a/protoc-gen-grpc-gateway/descriptor/services_test.go b/protoc-gen-grpc-gateway/descriptor/services_test.go index 93a8f67ce05..8f766708226 100644 --- a/protoc-gen-grpc-gateway/descriptor/services_test.go +++ b/protoc-gen-grpc-gateway/descriptor/services_test.go @@ -902,6 +902,49 @@ func TestExtractServicesWithError(t *testing.T) { `, }, }, + // 2nd-level field in body + { + target: "path/to/example.proto", + srcs: []string{ + ` + name: "path/to/example.proto", + package: "example" + message_type < + name: "OuterMessage" + nested_type < + name: "StringMessage" + field < + name: "string" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + > + > + field < + name: "nested" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: "StringMessage" + > + > + service < + name: "ExampleService" + method < + name: "Echo" + input_type: "OuterMessage" + output_type: "OuterMessage" + options < + [google.api.http] < + post: "/v1/example/echo" + body: "nested.string" + > + > + > + > + `, + }, + }, } { reg := NewRegistry() diff --git a/protoc-gen-grpc-gateway/descriptor/types.go b/protoc-gen-grpc-gateway/descriptor/types.go index 6346b68e956..37125d7594b 100644 --- a/protoc-gen-grpc-gateway/descriptor/types.go +++ b/protoc-gen-grpc-gateway/descriptor/types.go @@ -1,8 +1,10 @@ package descriptor import ( + "bytes" "fmt" "strings" + "text/template" descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" gogen "github.com/golang/protobuf/protoc-gen-go/generator" @@ -260,6 +262,29 @@ func (p FieldPath) IsNestedProto3() bool { return false } +type oneofParams struct { + // MsgExpr is the the expresson for the message which the oneof field belongs to. + MsgExpr string + // OneofName is the name of the oneof field in the message + OneofName string + // ConcreteType is the type name of the concrete struct which implements the isXXX interface + ConcreteType string +} + +var ( + oneofTemplate = template.Must(template.New("oneof").Parse(` + func() *{{.ConcreteType}} { + msg := &{{.MsgExpr}} + oneof := msg.{{.OneofName}} + if _, ok := oneof.(*{{.ConcreteType}}); oneof == nil || !ok { + oneof = new({{.ConcreteType}}) + msg.{{.OneofName}} = oneof + } + return oneof.(*{{.ConcreteType}}) + }()`, + )) +) + // AssignableExpr is an assignable expression in Go to be used to assign a value to the target field. // It starts with "msgExpr", which is the go expression of the method request object. func (p FieldPath) AssignableExpr(msgExpr string) string { @@ -268,36 +293,37 @@ func (p FieldPath) AssignableExpr(msgExpr string) string { return msgExpr } - var preparations []string - components := msgExpr + components := []string{msgExpr} for i, c := range p { // Check if it is a oneOf field. if c.Target.OneofIndex != nil { - index := c.Target.OneofIndex - msg := c.Target.Message - oneOfName := gogen.CamelCase(msg.GetOneofDecl()[*index].GetName()) - oneofFieldName := msg.GetName() + "_" + c.AssignableExpr() - - components = components + "." + oneOfName - s := `if %s == nil { - %s =&%s{} - } else if _, ok := %s.(*%s); !ok { - return nil, metadata, grpc.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s) - }` - - preparations = append(preparations, fmt.Sprintf(s, components, components, oneofFieldName, components, oneofFieldName, oneofFieldName, components)) - components = components + ".(*" + oneofFieldName + ")" + var ( + index = c.Target.OneofIndex + msg = c.Target.Message + buf bytes.Buffer + ) + // TODO(yugui) Use the package which the caller tempalte is dealing with. + // it will be necessary to correctly deal with oneof fields in messges in another packages than the service. + err := oneofTemplate.Execute(&buf, &oneofParams{ + MsgExpr: strings.Join(components, "."), + OneofName: gogen.CamelCase(msg.GetOneofDecl()[*index].GetName()), + //ConcreteType: msg.GetName() + "_" + c.AssignableExpr(), + ConcreteType: msg.GoType(msg.File.GoPkg.Path) + "_" + c.AssignableExpr(), + }) + if err != nil { + panic(fmt.Sprintf("cannot apply oneofTemplate: %v", err)) + } + components = []string{buf.String()} } if i == l-1 { - components = components + "." + c.AssignableExpr() + components = append(components, c.AssignableExpr()) continue } - components = components + "." + c.ValueExpr() + components = append(components, c.ValueExpr()) } - preparations = append(preparations, components) - return strings.Join(preparations, "\n") + return strings.Join(components, ".") } // FieldPathComponent is a path component in FieldPath @@ -323,6 +349,8 @@ func (c FieldPathComponent) ValueExpr() string { } var ( + // The table entries are ordered by enum numbers of the keys. + proto3ConvertFuncs = map[descriptor.FieldDescriptorProto_Type]string{ descriptor.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64", descriptor.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32", @@ -368,6 +396,8 @@ var ( descriptor.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64P", } + // wellKnownTypeConv keeps conversion functions for well-known + // but not primitive types. wellKnownTypeConv = map[string]string{ ".google.protobuf.Timestamp": "runtime.Timestamp", ".google.protobuf.Duration": "runtime.Duration", diff --git a/runtime/marshal_json_test.go b/runtime/marshal_json_test.go index 6ab9699e48c..b74af53c31a 100644 --- a/runtime/marshal_json_test.go +++ b/runtime/marshal_json_test.go @@ -219,7 +219,7 @@ var ( json: "ONE", }, { - data: &examplepb.ABitOfEverything_OneofString{OneofString: "abc"}, + data: &examplepb.ABitOfEverything_OneofValueString{OneofValueString: "abc"}, json: `"abc"`, }, { diff --git a/runtime/marshal_jsonpb_test.go b/runtime/marshal_jsonpb_test.go index 679283b4511..c18fa90f50f 100644 --- a/runtime/marshal_jsonpb_test.go +++ b/runtime/marshal_jsonpb_test.go @@ -34,8 +34,8 @@ func TestJSONPbMarshal(t *testing.T) { }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, - OneofValue: &examplepb.ABitOfEverything_OneofString{ - OneofString: "bar", + OneofValue: &examplepb.ABitOfEverything_OneofValueString{ + OneofValueString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, @@ -157,7 +157,7 @@ func TestJSONPbUnmarshal(t *testing.T) { ], "uint64Value": 18446744073709551615, "enumValue": "ONE", - "oneofString": "bar", + "oneofValueString": "bar", "mapValue": { "a": 1, "b": 0 @@ -170,7 +170,7 @@ func TestJSONPbUnmarshal(t *testing.T) { ], "uint64Value": "18446744073709551615", "enumValue": "ONE", - "oneofString": "bar", + "oneofValueString": "bar", "mapValue": { "a": 1, "b": 0 @@ -183,7 +183,7 @@ func TestJSONPbUnmarshal(t *testing.T) { ], "uint64Value": 18446744073709551615, "enumValue": 1, - "oneofString": "bar", + "oneofValueString": "bar", "mapValue": { "a": 1, "b": 0 @@ -204,8 +204,8 @@ func TestJSONPbUnmarshal(t *testing.T) { }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, - OneofValue: &examplepb.ABitOfEverything_OneofString{ - OneofString: "bar", + OneofValue: &examplepb.ABitOfEverything_OneofValueString{ + OneofValueString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, @@ -252,8 +252,8 @@ func TestJSONPbEncoder(t *testing.T) { }, }, Uint64Value: 0xFFFFFFFFFFFFFFFF, - OneofValue: &examplepb.ABitOfEverything_OneofString{ - OneofString: "bar", + OneofValue: &examplepb.ABitOfEverything_OneofValueString{ + OneofValueString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, @@ -375,7 +375,7 @@ func TestJSONPbDecoder(t *testing.T) { ], "uint64Value": 18446744073709551615, "enumValue": "ONE", - "oneofString": "bar", + "oneofValueString": "bar", "mapValue": { "a": 1, "b": 0 @@ -388,7 +388,7 @@ func TestJSONPbDecoder(t *testing.T) { ], "uint64Value": "18446744073709551615", "enumValue": "ONE", - "oneofString": "bar", + "oneofValueString": "bar", "mapValue": { "a": 1, "b": 0 @@ -401,7 +401,7 @@ func TestJSONPbDecoder(t *testing.T) { ], "uint64Value": 18446744073709551615, "enumValue": 1, - "oneofString": "bar", + "oneofValueString": "bar", "mapValue": { "a": 1, "b": 0 @@ -424,8 +424,8 @@ func TestJSONPbDecoder(t *testing.T) { }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, - OneofValue: &examplepb.ABitOfEverything_OneofString{ - OneofString: "bar", + OneofValue: &examplepb.ABitOfEverything_OneofValueString{ + OneofValueString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, diff --git a/runtime/marshal_proto_test.go b/runtime/marshal_proto_test.go index 535f3991d9d..eae06dbe450 100644 --- a/runtime/marshal_proto_test.go +++ b/runtime/marshal_proto_test.go @@ -26,8 +26,8 @@ var message = &examplepb.ABitOfEverything{ }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, - OneofValue: &examplepb.ABitOfEverything_OneofString{ - OneofString: "bar", + OneofValue: &examplepb.ABitOfEverything_OneofValueString{ + OneofValueString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, diff --git a/runtime/query.go b/runtime/query.go index 07d0ff8c5bf..6fa5c2ad2de 100644 --- a/runtime/query.go +++ b/runtime/query.go @@ -30,6 +30,12 @@ func PopulateQueryParameters(msg proto.Message, values url.Values, filter *utili } fieldPath := strings.Split(key, ".") if filter.HasCommonPrefix(fieldPath) { + // Query parameters never overwrite explicitly declared parameters. + // ref. https://groups.google.com/d/msg/grpc-io/Xqx80hG0D44/1gwmwBcnNScJ + // + // ref. https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L73 + // > Any fields in the request message which are not bound by the path + // > pattern automatically become (optional) HTTP query continue } if err := populateFieldValueFromPath(msg, fieldPath, values); err != nil {