From bc610ef456dfbdba336ee8a37087e0b1cec07b50 Mon Sep 17 00:00:00 2001 From: Tommy PAGEARD Date: Wed, 26 Sep 2018 14:57:58 +0200 Subject: [PATCH] update files after rebase from master --- examples/clients/abe/.swagger-codegen/VERSION | 1 + .../clients/abe/a_bit_of_everything_nested.go | 8 +- .../abe/a_bit_of_everything_service_api.go | 1444 +++++++++------- examples/clients/abe/api/swagger.yaml | 1281 ++++++++++++++ examples/clients/abe/api_client.go | 425 ++++- examples/clients/abe/api_response.go | 6 +- .../abe/camel_case_service_name_api.go | 124 +- examples/clients/abe/configuration.go | 84 +- examples/clients/abe/echo_rpc_api.go | 322 ++-- examples/clients/abe/echo_service_api.go | 322 ++-- .../abe/examplepb_a_bit_of_everything.go | 16 +- .../examplepb_a_bit_of_everything_repeated.go | 6 +- examples/clients/abe/examplepb_body.go | 6 +- .../clients/abe/examplepb_numeric_enum.go | 16 +- .../abe/message_path_enum_nested_path_enum.go | 15 +- examples/clients/abe/nested_deep_enum.go | 16 +- examples/clients/abe/pathenum_path_enum.go | 15 +- examples/clients/abe/protobuf_empty.go | 6 +- examples/clients/abe/sub_string_message.go | 6 +- .../clients/echo/.swagger-codegen/VERSION | 1 + examples/clients/echo/api/swagger.yaml | 407 +++++ examples/clients/echo/api_client.go | 420 ++++- examples/clients/echo/api_response.go | 7 +- examples/clients/echo/configuration.go | 85 +- examples/clients/echo/echo_service_api.go | 823 +++++---- examples/clients/echo/examplepb_embedded.go | 7 +- .../clients/echo/examplepb_simple_message.go | 11 +- .../responsebody/.swagger-codegen/VERSION | 1 + .../clients/responsebody/api/swagger.yaml | 42 + examples/clients/responsebody/api_client.go | 420 ++++- examples/clients/responsebody/api_response.go | 7 +- .../clients/responsebody/configuration.go | 85 +- .../docs/ExamplepbResponseBodyOut.md | 2 +- .../docs/ResponseBodyServiceApi.md | 9 +- .../examplepb_response_body_out.go | 9 +- .../examplepb_response_body_out_response.go | 7 +- .../responsebody/response_body_service_api.go | 100 +- .../unannotatedecho/.swagger-codegen/VERSION | 1 + .../clients/unannotatedecho/api/swagger.yaml | 131 ++ .../clients/unannotatedecho/api_client.go | 420 ++++- .../clients/unannotatedecho/api_response.go | 7 +- .../clients/unannotatedecho/configuration.go | 85 +- .../examplepb_unannotated_simple_message.go | 7 +- .../unannotated_echo_service_api.go | 336 ++-- .../proto/examplepb/a_bit_of_everything.pb.go | 18 +- .../examplepb/a_bit_of_everything.pb.gw.go | 87 - examples/proto/examplepb/echo_service.pb.go | 8 +- .../proto/examplepb/flow_combination.pb.go | 14 +- .../examplepb/response_body_service.pb.go | 10 +- examples/proto/examplepb/stream.pb.go | 4 +- .../examplepb/unannotated_echo_service.pb.go | 6 +- examples/proto/examplepb/wrappers.pb.go | 6 +- examples/proto/pathenum/path_enum.pb.go | 10 +- examples/proto/sub/message.pb.go | 6 +- examples/proto/sub2/message.pb.go | 6 +- protoc-gen-swagger/options/annotations.pb.go | 103 -- protoc-gen-swagger/options/openapiv2.pb.go | 1469 ----------------- runtime/internal/stream_chunk.pb.go | 6 +- 58 files changed, 5512 insertions(+), 3790 deletions(-) create mode 100644 examples/clients/abe/.swagger-codegen/VERSION create mode 100644 examples/clients/abe/api/swagger.yaml create mode 100644 examples/clients/echo/.swagger-codegen/VERSION create mode 100644 examples/clients/echo/api/swagger.yaml create mode 100644 examples/clients/responsebody/.swagger-codegen/VERSION create mode 100644 examples/clients/responsebody/api/swagger.yaml create mode 100644 examples/clients/unannotatedecho/.swagger-codegen/VERSION create mode 100644 examples/clients/unannotatedecho/api/swagger.yaml delete mode 100644 protoc-gen-swagger/options/annotations.pb.go delete mode 100644 protoc-gen-swagger/options/openapiv2.pb.go diff --git a/examples/clients/abe/.swagger-codegen/VERSION b/examples/clients/abe/.swagger-codegen/VERSION new file mode 100644 index 00000000000..717311e32e3 --- /dev/null +++ b/examples/clients/abe/.swagger-codegen/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/examples/clients/abe/a_bit_of_everything_nested.go b/examples/clients/abe/a_bit_of_everything_nested.go index 095e8c5f118..3ed0110d6be 100644 --- a/examples/clients/abe/a_bit_of_everything_nested.go +++ b/examples/clients/abe/a_bit_of_everything_nested.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe @@ -18,5 +18,5 @@ type ABitOfEverythingNested struct { Amount int64 `json:"amount,omitempty"` - Ok NestedDeepEnum `json:"ok,omitempty"` + Ok *NestedDeepEnum `json:"ok,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 d1f2a1f95e9..e6d3fc675a8 100644 --- a/examples/clients/abe/a_bit_of_everything_service_api.go +++ b/examples/clients/abe/a_bit_of_everything_service_api.go @@ -1,72 +1,67 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "time" "encoding/json" "fmt" ) -type ABitOfEverythingServiceApi struct { - Configuration *Configuration -} - -func NewABitOfEverythingServiceApi() *ABitOfEverythingServiceApi { - configuration := NewConfiguration() - return &ABitOfEverythingServiceApi{ - Configuration: configuration, - } -} - -func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythingServiceApi { - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &ABitOfEverythingServiceApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -/** - * Create a new ABitOfEverything - * This API creates a new ABitOfEverything - * - * @param floatValue - * @param doubleValue - * @param int64Value - * @param uint64Value - * @param int32Value - * @param fixed64Value - * @param fixed32Value - * @param boolValue - * @param stringValue - * @param uint32Value - * @param sfixed32Value - * @param sfixed64Value - * @param sint32Value - * @param sint64Value - * @param nonConventionalNameValue - * @param enumValue - * @param pathEnumValue - * @param nestedPathEnumValue - * @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, enumValue string, pathEnumValue string, nestedPathEnumValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { +type ABitOfEverythingServiceApiService service + + +/* ABitOfEverythingServiceApiService Create a new ABitOfEverything + This API creates a new ABitOfEverything + * @param ctx context.Context for authentication, logging, tracing, etc. + @param floatValue + @param doubleValue + @param int64Value + @param uint64Value + @param int32Value + @param fixed64Value + @param fixed32Value + @param boolValue + @param stringValue + @param uint32Value + @param sfixed32Value + @param sfixed64Value + @param sint32Value + @param sint64Value + @param nonConventionalNameValue + @param enumValue + @param pathEnumValue + @param nestedPathEnumValue + @return ExamplepbABitOfEverything*/ +func (a *ABitOfEverythingServiceApiService) Create(ctx context.Context, 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, enumValue string, pathEnumValue string, nestedPathEnumValue string) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbABitOfEverything + ) - 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}/{enum_value}/{path_enum_value}/{nested_path_enum_value}" + localVarPath := a.client.cfg.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}/{enum_value}/{path_enum_value}/{nested_path_enum_value}" 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) @@ -88,36 +83,18 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -125,72 +102,75 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := 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) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Create", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param body - * @return *ExamplepbABitOfEverything - */ -func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param body + @return ExamplepbABitOfEverything*/ +func (a *ABitOfEverythingServiceApiService) CreateBody(ctx context.Context, body ExamplepbABitOfEverything) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbABitOfEverything + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything" 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -198,76 +178,79 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := 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) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "CreateBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param singleNestedName name is nested field. - * @param body - * @return *ExamplepbABitOfEverything - */ -func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param singleNestedName name is nested field. + @param body + @return ExamplepbABitOfEverything*/ +func (a *ABitOfEverythingServiceApiService) DeepPathEcho(ctx context.Context, singleNestedName string, body ExamplepbABitOfEverything) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbABitOfEverything + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/{single_nested.name}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{single_nested.name}" localVarPath = strings.Replace(localVarPath, "{"+"single_nested.name"+"}", fmt.Sprintf("%v", singleNestedName), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -275,70 +258,78 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := 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) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - 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() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param uuid - * @return *ProtobufEmpty - */ -func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param uuid + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) Delete(ctx context.Context, uuid string) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/{uuid}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -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 '(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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -346,71 +337,74 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Delete", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @return *ProtobufEmpty - */ -func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) ErrorWithDetails(ctx context.Context) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/errorwithdetails" + localVarPath := a.client.cfg.BasePath + "/v2/example/errorwithdetails" 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -418,74 +412,77 @@ func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*ProtobufEmpty, *APIResp } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "ErrorWithDetails", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param id - * @param body - * @return *ProtobufEmpty - */ -func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id + @param body + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) GetMessageWithBody(ctx context.Context, id string, body ExamplepbBody) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/withbody/{id}" + localVarPath := a.client.cfg.BasePath + "/v2/example/withbody/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -493,118 +490,255 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "GetMessageWithBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param uuid - * @param singleNestedName name is nested field. - * @param singleNestedAmount - * @param singleNestedOk - FALSE: FALSE is false. - TRUE: TRUE is true. - * @param floatValue - * @param doubleValue - * @param int64Value - * @param uint64Value - * @param int32Value - * @param fixed64Value - * @param fixed32Value - * @param boolValue - * @param stringValue - * @param bytesValue - * @param uint32Value - * @param enumValue - ZERO: ZERO means 0 - ONE: ONE means 1 - * @param pathEnumValue - * @param nestedPathEnumValue - * @param sfixed32Value - * @param sfixed64Value - * @param sint32Value - * @param sint64Value - * @param repeatedStringValue - * @param oneofString - * @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, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param uuid + @param optional (nil or map[string]interface{}) with one or more of: + @param "singleNestedName" (string) name is nested field. + @param "singleNestedAmount" (int64) + @param "singleNestedOk" (string) - FALSE: FALSE is false. - TRUE: TRUE is true. + @param "floatValue" (float32) + @param "doubleValue" (float64) + @param "int64Value" (string) + @param "uint64Value" (string) + @param "int32Value" (int32) + @param "fixed64Value" (string) + @param "fixed32Value" (int64) + @param "boolValue" (bool) + @param "stringValue" (string) + @param "bytesValue" (string) + @param "uint32Value" (int64) + @param "enumValue" (string) - ZERO: ZERO means 0 - ONE: ONE means 1 + @param "pathEnumValue" (string) + @param "nestedPathEnumValue" (string) + @param "sfixed32Value" (int32) + @param "sfixed64Value" (string) + @param "sint32Value" (int32) + @param "sint64Value" (string) + @param "repeatedStringValue" ([]string) + @param "oneofString" (string) + @param "nonConventionalNameValue" (string) + @param "timestampValue" (time.Time) + @param "repeatedEnumValue" ([]string) repeated enum value. it is comma-separated in query. - ZERO: ZERO means 0 - ONE: ONE means 1 + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) GetQuery(ctx context.Context, uuid string, localVarOptionals map[string]interface{}) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/query/{uuid}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/query/{uuid}" localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -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("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("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, "")) - localVarQueryParams.Add("uint64_value", a.Configuration.APIClient.ParameterToString(uint64Value, "")) - localVarQueryParams.Add("int32_value", a.Configuration.APIClient.ParameterToString(int32Value, "")) - localVarQueryParams.Add("fixed64_value", a.Configuration.APIClient.ParameterToString(fixed64Value, "")) - localVarQueryParams.Add("fixed32_value", a.Configuration.APIClient.ParameterToString(fixed32Value, "")) - localVarQueryParams.Add("bool_value", a.Configuration.APIClient.ParameterToString(boolValue, "")) - localVarQueryParams.Add("string_value", a.Configuration.APIClient.ParameterToString(stringValue, "")) - localVarQueryParams.Add("bytes_value", a.Configuration.APIClient.ParameterToString(bytesValue, "")) - localVarQueryParams.Add("uint32_value", a.Configuration.APIClient.ParameterToString(uint32Value, "")) - localVarQueryParams.Add("enum_value", a.Configuration.APIClient.ParameterToString(enumValue, "")) - localVarQueryParams.Add("path_enum_value", a.Configuration.APIClient.ParameterToString(pathEnumValue, "")) - localVarQueryParams.Add("nested_path_enum_value", a.Configuration.APIClient.ParameterToString(nestedPathEnumValue, "")) - localVarQueryParams.Add("sfixed32_value", a.Configuration.APIClient.ParameterToString(sfixed32Value, "")) - localVarQueryParams.Add("sfixed64_value", a.Configuration.APIClient.ParameterToString(sfixed64Value, "")) - localVarQueryParams.Add("sint32_value", a.Configuration.APIClient.ParameterToString(sint32Value, "")) - localVarQueryParams.Add("sint64_value", a.Configuration.APIClient.ParameterToString(sint64Value, "")) - 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("nonConventionalNameValue", a.Configuration.APIClient.ParameterToString(nonConventionalNameValue, "")) - localVarQueryParams.Add("timestamp_value", a.Configuration.APIClient.ParameterToString(timestampValue, "")) - var repeatedEnumValueCollectionFormat = "csv" - localVarQueryParams.Add("repeated_enum_value", a.Configuration.APIClient.ParameterToString(repeatedEnumValue, repeatedEnumValueCollectionFormat)) + localVarFormParams := url.Values{} + if err := typeCheckParameter(localVarOptionals["singleNestedName"], "string", "singleNestedName"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["singleNestedAmount"], "int64", "singleNestedAmount"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["singleNestedOk"], "string", "singleNestedOk"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["floatValue"], "float32", "floatValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["doubleValue"], "float64", "doubleValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["int64Value"], "string", "int64Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["uint64Value"], "string", "uint64Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["int32Value"], "int32", "int32Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["fixed64Value"], "string", "fixed64Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["fixed32Value"], "int64", "fixed32Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["boolValue"], "bool", "boolValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["stringValue"], "string", "stringValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["bytesValue"], "string", "bytesValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["uint32Value"], "int64", "uint32Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["enumValue"], "string", "enumValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["pathEnumValue"], "string", "pathEnumValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["nestedPathEnumValue"], "string", "nestedPathEnumValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["sfixed32Value"], "int32", "sfixed32Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["sfixed64Value"], "string", "sfixed64Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["sint32Value"], "int32", "sint32Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["sint64Value"], "string", "sint64Value"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["oneofString"], "string", "oneofString"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["nonConventionalNameValue"], "string", "nonConventionalNameValue"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["timestampValue"], "time.Time", "timestampValue"); err != nil { + return successPayload, nil, err + } + if localVarTempParam, localVarOk := localVarOptionals["singleNestedName"].(string); localVarOk { + localVarQueryParams.Add("single_nested.name", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["singleNestedAmount"].(int64); localVarOk { + localVarQueryParams.Add("single_nested.amount", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["singleNestedOk"].(string); localVarOk { + localVarQueryParams.Add("single_nested.ok", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["floatValue"].(float32); localVarOk { + localVarQueryParams.Add("float_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["doubleValue"].(float64); localVarOk { + localVarQueryParams.Add("double_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["int64Value"].(string); localVarOk { + localVarQueryParams.Add("int64_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["uint64Value"].(string); localVarOk { + localVarQueryParams.Add("uint64_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["int32Value"].(int32); localVarOk { + localVarQueryParams.Add("int32_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["fixed64Value"].(string); localVarOk { + localVarQueryParams.Add("fixed64_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["fixed32Value"].(int64); localVarOk { + localVarQueryParams.Add("fixed32_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["boolValue"].(bool); localVarOk { + localVarQueryParams.Add("bool_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["stringValue"].(string); localVarOk { + localVarQueryParams.Add("string_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["bytesValue"].(string); localVarOk { + localVarQueryParams.Add("bytes_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["uint32Value"].(int64); localVarOk { + localVarQueryParams.Add("uint32_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["enumValue"].(string); localVarOk { + localVarQueryParams.Add("enum_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["pathEnumValue"].(string); localVarOk { + localVarQueryParams.Add("path_enum_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["nestedPathEnumValue"].(string); localVarOk { + localVarQueryParams.Add("nested_path_enum_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["sfixed32Value"].(int32); localVarOk { + localVarQueryParams.Add("sfixed32_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["sfixed64Value"].(string); localVarOk { + localVarQueryParams.Add("sfixed64_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["sint32Value"].(int32); localVarOk { + localVarQueryParams.Add("sint32_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["sint64Value"].(string); localVarOk { + localVarQueryParams.Add("sint64_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["repeatedStringValue"].([]string); localVarOk { + localVarQueryParams.Add("repeated_string_value", parameterToString(localVarTempParam, "csv")) + } + if localVarTempParam, localVarOk := localVarOptionals["oneofString"].(string); localVarOk { + localVarQueryParams.Add("oneof_string", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["nonConventionalNameValue"].(string); localVarOk { + localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["timestampValue"].(time.Time); localVarOk { + localVarQueryParams.Add("timestamp_value", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["repeatedEnumValue"].([]string); localVarOk { + localVarQueryParams.Add("repeated_enum_value", parameterToString(localVarTempParam, "csv")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -612,54 +746,63 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "GetQuery", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param pathRepeatedFloatValue repeated values. they are comma-separated in path - * @param pathRepeatedDoubleValue - * @param pathRepeatedInt64Value - * @param pathRepeatedUint64Value - * @param pathRepeatedInt32Value - * @param pathRepeatedFixed64Value - * @param pathRepeatedFixed32Value - * @param pathRepeatedBoolValue - * @param pathRepeatedStringValue - * @param pathRepeatedBytesValue - * @param pathRepeatedUint32Value - * @param pathRepeatedEnumValue - * @param pathRepeatedSfixed32Value - * @param pathRepeatedSfixed64Value - * @param pathRepeatedSint32Value - * @param pathRepeatedSint64Value - * @return *ExamplepbABitOfEverythingRepeated - */ -func (a ABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (*ExamplepbABitOfEverythingRepeated, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param pathRepeatedFloatValue repeated values. they are comma-separated in path + @param pathRepeatedDoubleValue + @param pathRepeatedInt64Value + @param pathRepeatedUint64Value + @param pathRepeatedInt32Value + @param pathRepeatedFixed64Value + @param pathRepeatedFixed32Value + @param pathRepeatedBoolValue + @param pathRepeatedStringValue + @param pathRepeatedBytesValue + @param pathRepeatedUint32Value + @param pathRepeatedEnumValue + @param pathRepeatedSfixed32Value + @param pathRepeatedSfixed64Value + @param pathRepeatedSint32Value + @param pathRepeatedSint64Value + @return ExamplepbABitOfEverythingRepeated*/ +func (a *ABitOfEverythingServiceApiService) GetRepeatedQuery(ctx context.Context, pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (ExamplepbABitOfEverythingRepeated, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbABitOfEverythingRepeated + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value}" localVarPath = strings.Replace(localVarPath, "{"+"path_repeated_float_value"+"}", fmt.Sprintf("%v", pathRepeatedFloatValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"path_repeated_double_value"+"}", fmt.Sprintf("%v", pathRepeatedDoubleValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"path_repeated_int64_value"+"}", fmt.Sprintf("%v", pathRepeatedInt64Value), -1) @@ -679,36 +822,66 @@ func (a ABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []fl 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] + localVarFormParams := url.Values{} + + if len(pathRepeatedFloatValue) < 1 { + return successPayload, nil, reportError("pathRepeatedFloatValue must have at least 1 elements") + } + if len(pathRepeatedDoubleValue) < 1 { + return successPayload, nil, reportError("pathRepeatedDoubleValue must have at least 1 elements") + } + if len(pathRepeatedInt64Value) < 1 { + return successPayload, nil, reportError("pathRepeatedInt64Value must have at least 1 elements") + } + if len(pathRepeatedUint64Value) < 1 { + return successPayload, nil, reportError("pathRepeatedUint64Value must have at least 1 elements") + } + if len(pathRepeatedInt32Value) < 1 { + return successPayload, nil, reportError("pathRepeatedInt32Value must have at least 1 elements") + } + if len(pathRepeatedFixed64Value) < 1 { + return successPayload, nil, reportError("pathRepeatedFixed64Value must have at least 1 elements") + } + if len(pathRepeatedFixed32Value) < 1 { + return successPayload, nil, reportError("pathRepeatedFixed32Value must have at least 1 elements") + } + if len(pathRepeatedBoolValue) < 1 { + return successPayload, nil, reportError("pathRepeatedBoolValue must have at least 1 elements") + } + if len(pathRepeatedStringValue) < 1 { + return successPayload, nil, reportError("pathRepeatedStringValue must have at least 1 elements") + } + if len(pathRepeatedBytesValue) < 1 { + return successPayload, nil, reportError("pathRepeatedBytesValue must have at least 1 elements") + } + if len(pathRepeatedUint32Value) < 1 { + return successPayload, nil, reportError("pathRepeatedUint32Value must have at least 1 elements") + } + if len(pathRepeatedEnumValue) < 1 { + return successPayload, nil, reportError("pathRepeatedEnumValue must have at least 1 elements") + } + if len(pathRepeatedSfixed32Value) < 1 { + return successPayload, nil, reportError("pathRepeatedSfixed32Value must have at least 1 elements") + } + if len(pathRepeatedSfixed64Value) < 1 { + return successPayload, nil, reportError("pathRepeatedSfixed64Value must have at least 1 elements") + } + if len(pathRepeatedSint32Value) < 1 { + return successPayload, nil, reportError("pathRepeatedSint32Value must have at least 1 elements") + } + if len(pathRepeatedSint64Value) < 1 { + return successPayload, nil, reportError("pathRepeatedSint64Value must have at least 1 elements") } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -716,73 +889,76 @@ func (a ABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []fl } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ExamplepbABitOfEverythingRepeated) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "GetRepeatedQuery", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param uuid - * @return *ExamplepbABitOfEverything - */ -func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEverything, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param uuid + @return ExamplepbABitOfEverything*/ +func (a *ABitOfEverythingServiceApiService) Lookup(ctx context.Context, uuid string) (ExamplepbABitOfEverything, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbABitOfEverything + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/{uuid}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -790,74 +966,77 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := 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) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Lookup", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param name - * @param body - * @return *ProtobufEmpty - */ -func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param name + @param body + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) PostWithEmptyBody(ctx context.Context, name string, body ExamplepbBody) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/postwithemptybody/{name}" + localVarPath := a.client.cfg.BasePath + "/v2/example/postwithemptybody/{name}" localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -865,73 +1044,76 @@ func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body Examplep } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "PostWithEmptyBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @return *ProtobufEmpty - */ -func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) Timeout(ctx context.Context) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/timeout" + localVarPath := a.client.cfg.BasePath + "/v2/example/timeout" 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -939,74 +1121,77 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Timeout", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * - * - * @param uuid - * @param body - * @return *ProtobufEmpty - */ -func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*ProtobufEmpty, *APIResponse, error) { +/* ABitOfEverythingServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param uuid + @param body + @return ProtobufEmpty*/ +func (a *ABitOfEverythingServiceApiService) Update(ctx context.Context, uuid string, body ExamplepbABitOfEverything) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/{uuid}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -1014,27 +1199,44 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(ProtobufEmpty) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Update", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/clients/abe/api/swagger.yaml b/examples/clients/abe/api/swagger.yaml new file mode 100644 index 00000000000..5cbded56c0a --- /dev/null +++ b/examples/clients/abe/api/swagger.yaml @@ -0,0 +1,1281 @@ +--- +swagger: "2.0" +info: + version: "1.0" + title: "A Bit of Everything" + contact: + name: "gRPC-Gateway project" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + email: "none@example.com" +schemes: +- "http" +- "https" +- "wss" +consumes: +- "application/json" +- "application/x-foo-mime" +produces: +- "application/json" +- "application/x-foo-mime" +security: +- ApiKeyAuth: [] + BasicAuth: [] +- ApiKeyAuth: [] + OAuth2: + - "read" + - "write" +paths: + /v1/example/a_bit_of_everything: + post: + tags: + - "ABitOfEverythingService" + operationId: "CreateBody" + parameters: + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbABitOfEverything" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbABitOfEverything" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v1/example/a_bit_of_everything/echo/{value}: + get: + tags: + - "echo service" + - "echo rpc" + summary: "Summary: Echo rpc" + description: "Description Echo" + operationId: "Echo" + parameters: + - name: "value" + in: "path" + required: true + type: "string" + x-exportParamName: "Value" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/subStringMessage" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + 503: + description: "Returned when the resource is temporarily unavailable." + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + /v1/example/a_bit_of_everything/query/{uuid}: + get: + tags: + - "ABitOfEverythingService" + operationId: "GetQuery" + parameters: + - name: "uuid" + in: "path" + required: true + type: "string" + x-exportParamName: "Uuid" + - name: "single_nested.name" + in: "query" + description: "name is nested field." + required: false + type: "string" + x-exportParamName: "SingleNestedName" + - name: "single_nested.amount" + in: "query" + required: false + type: "integer" + format: "int64" + x-exportParamName: "SingleNestedAmount" + - name: "single_nested.ok" + in: "query" + description: " - FALSE: FALSE is false.\n - TRUE: TRUE is true." + required: false + type: "string" + default: "FALSE" + enum: + - "FALSE" + - "TRUE" + x-exportParamName: "SingleNestedOk" + - name: "float_value" + in: "query" + required: false + type: "number" + format: "float" + x-exportParamName: "FloatValue" + - name: "double_value" + in: "query" + required: false + type: "number" + format: "double" + x-exportParamName: "DoubleValue" + - name: "int64_value" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Int64Value" + - name: "uint64_value" + in: "query" + required: false + type: "string" + format: "uint64" + x-exportParamName: "Uint64Value" + - name: "int32_value" + in: "query" + required: false + type: "integer" + format: "int32" + x-exportParamName: "Int32Value" + - name: "fixed64_value" + in: "query" + required: false + type: "string" + format: "uint64" + x-exportParamName: "Fixed64Value" + - name: "fixed32_value" + in: "query" + required: false + type: "integer" + format: "int64" + x-exportParamName: "Fixed32Value" + - name: "bool_value" + in: "query" + required: false + type: "boolean" + format: "boolean" + x-exportParamName: "BoolValue" + - name: "string_value" + in: "query" + required: false + type: "string" + x-exportParamName: "StringValue" + - name: "bytes_value" + in: "query" + required: false + type: "string" + format: "byte" + x-exportParamName: "BytesValue" + - name: "uint32_value" + in: "query" + required: false + type: "integer" + format: "int64" + x-exportParamName: "Uint32Value" + - name: "enum_value" + in: "query" + description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" + required: false + type: "string" + default: "ZERO" + enum: + - "ZERO" + - "ONE" + x-exportParamName: "EnumValue" + - name: "path_enum_value" + in: "query" + required: false + type: "string" + default: "ABC" + enum: + - "ABC" + - "DEF" + x-exportParamName: "PathEnumValue" + - name: "nested_path_enum_value" + in: "query" + required: false + type: "string" + default: "GHI" + enum: + - "GHI" + - "JKL" + x-exportParamName: "NestedPathEnumValue" + - name: "sfixed32_value" + in: "query" + required: false + type: "integer" + format: "int32" + x-exportParamName: "Sfixed32Value" + - name: "sfixed64_value" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Sfixed64Value" + - name: "sint32_value" + in: "query" + required: false + type: "integer" + format: "int32" + x-exportParamName: "Sint32Value" + - name: "sint64_value" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Sint64Value" + - name: "repeated_string_value" + in: "query" + required: false + type: "array" + items: + type: "string" + x-exportParamName: "RepeatedStringValue" + - name: "oneof_string" + in: "query" + required: false + type: "string" + x-exportParamName: "OneofString" + - name: "nonConventionalNameValue" + in: "query" + required: false + type: "string" + x-exportParamName: "NonConventionalNameValue" + - name: "timestamp_value" + in: "query" + required: false + type: "string" + format: "date-time" + x-exportParamName: "TimestampValue" + - name: "repeated_enum_value" + in: "query" + description: "repeated enum value. it is comma-separated in query.\n\n - ZERO:\ + \ ZERO means 0\n - ONE: ONE means 1" + required: false + type: "array" + items: + type: "string" + enum: + - "ZERO" + - "ONE" + x-exportParamName: "RepeatedEnumValue" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + security: [] + externalDocs: + description: "Find out more about GetQuery" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + deprecated: true + ? /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}/{enum_value}/{path_enum_value}/{nested_path_enum_value} + : post: + tags: + - "ABitOfEverythingService" + summary: "Create a new ABitOfEverything" + description: "This API creates a new ABitOfEverything" + operationId: "Create" + parameters: + - name: "float_value" + in: "path" + required: true + type: "number" + format: "float" + x-exportParamName: "FloatValue" + - name: "double_value" + in: "path" + required: true + type: "number" + format: "double" + x-exportParamName: "DoubleValue" + - name: "int64_value" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "Int64Value" + - name: "uint64_value" + in: "path" + required: true + type: "string" + format: "uint64" + x-exportParamName: "Uint64Value" + - name: "int32_value" + in: "path" + required: true + type: "integer" + format: "int32" + x-exportParamName: "Int32Value" + - name: "fixed64_value" + in: "path" + required: true + type: "string" + format: "uint64" + x-exportParamName: "Fixed64Value" + - name: "fixed32_value" + in: "path" + required: true + type: "integer" + format: "int64" + x-exportParamName: "Fixed32Value" + - name: "bool_value" + in: "path" + required: true + type: "boolean" + format: "boolean" + x-exportParamName: "BoolValue" + - name: "string_value" + in: "path" + required: true + type: "string" + x-exportParamName: "StringValue" + - name: "uint32_value" + in: "path" + required: true + type: "integer" + format: "int64" + x-exportParamName: "Uint32Value" + - name: "sfixed32_value" + in: "path" + required: true + type: "integer" + format: "int32" + x-exportParamName: "Sfixed32Value" + - name: "sfixed64_value" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "Sfixed64Value" + - name: "sint32_value" + in: "path" + required: true + type: "integer" + format: "int32" + x-exportParamName: "Sint32Value" + - name: "sint64_value" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "Sint64Value" + - name: "nonConventionalNameValue" + in: "path" + required: true + type: "string" + x-exportParamName: "NonConventionalNameValue" + - name: "enum_value" + in: "path" + required: true + type: "string" + enum: + - "ZERO" + - "ONE" + x-exportParamName: "EnumValue" + - name: "path_enum_value" + in: "path" + required: true + type: "string" + enum: + - "ABC" + - "DEF" + x-exportParamName: "PathEnumValue" + - name: "nested_path_enum_value" + in: "path" + required: true + type: "string" + enum: + - "GHI" + - "JKL" + x-exportParamName: "NestedPathEnumValue" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbABitOfEverything" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v1/example/a_bit_of_everything/{single_nested.name}: + post: + tags: + - "ABitOfEverythingService" + operationId: "DeepPathEcho" + parameters: + - name: "single_nested.name" + in: "path" + description: "name is nested field." + required: true + type: "string" + x-exportParamName: "SingleNestedName" + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbABitOfEverything" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbABitOfEverything" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v1/example/a_bit_of_everything/{uuid}: + get: + tags: + - "ABitOfEverythingService" + operationId: "Lookup" + parameters: + - name: "uuid" + in: "path" + required: true + type: "string" + x-exportParamName: "Uuid" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbABitOfEverything" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + put: + tags: + - "ABitOfEverythingService" + operationId: "Update" + parameters: + - name: "uuid" + in: "path" + required: true + type: "string" + x-exportParamName: "Uuid" + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbABitOfEverything" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + delete: + tags: + - "ABitOfEverythingService" + operationId: "Delete" + parameters: + - name: "uuid" + in: "path" + required: true + type: "string" + x-exportParamName: "Uuid" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + security: + - ApiKeyAuth: [] + OAuth2: + - "read" + - "write" + ? /v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value} + : get: + tags: + - "ABitOfEverythingService" + operationId: "GetRepeatedQuery" + parameters: + - name: "path_repeated_float_value" + in: "path" + description: "repeated values. they are comma-separated in path" + required: true + type: "array" + items: + type: "number" + format: "float" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedFloatValue" + - name: "path_repeated_double_value" + in: "path" + required: true + type: "array" + items: + type: "number" + format: "double" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedDoubleValue" + - name: "path_repeated_int64_value" + in: "path" + required: true + type: "array" + items: + type: "string" + format: "int64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedInt64Value" + - name: "path_repeated_uint64_value" + in: "path" + required: true + type: "array" + items: + type: "string" + format: "uint64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedUint64Value" + - name: "path_repeated_int32_value" + in: "path" + required: true + type: "array" + items: + type: "integer" + format: "int32" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedInt32Value" + - name: "path_repeated_fixed64_value" + in: "path" + required: true + type: "array" + items: + type: "string" + format: "uint64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedFixed64Value" + - name: "path_repeated_fixed32_value" + in: "path" + required: true + type: "array" + items: + type: "integer" + format: "int64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedFixed32Value" + - name: "path_repeated_bool_value" + in: "path" + required: true + type: "array" + items: + type: "boolean" + format: "boolean" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedBoolValue" + - name: "path_repeated_string_value" + in: "path" + required: true + type: "array" + items: + type: "string" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedStringValue" + - name: "path_repeated_bytes_value" + in: "path" + required: true + type: "array" + items: + type: "string" + format: "byte" + pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedBytesValue" + - name: "path_repeated_uint32_value" + in: "path" + required: true + type: "array" + items: + type: "integer" + format: "int64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedUint32Value" + - name: "path_repeated_enum_value" + in: "path" + required: true + type: "array" + items: + type: "string" + enum: + - "ZERO" + - "ONE" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedEnumValue" + - name: "path_repeated_sfixed32_value" + in: "path" + required: true + type: "array" + items: + type: "integer" + format: "int32" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedSfixed32Value" + - name: "path_repeated_sfixed64_value" + in: "path" + required: true + type: "array" + items: + type: "string" + format: "int64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedSfixed64Value" + - name: "path_repeated_sint32_value" + in: "path" + required: true + type: "array" + items: + type: "integer" + format: "int32" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedSint32Value" + - name: "path_repeated_sint64_value" + in: "path" + required: true + type: "array" + items: + type: "string" + format: "int64" + collectionFormat: "csv" + minItems: 1 + x-exportParamName: "PathRepeatedSint64Value" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbABitOfEverythingRepeated" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v2/example/echo: + get: + tags: + - "echo service" + - "echo rpc" + summary: "Summary: Echo rpc" + description: "Description Echo" + operationId: "Echo3" + parameters: + - name: "value" + in: "query" + required: false + type: "string" + x-exportParamName: "Value" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/subStringMessage" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + 503: + description: "Returned when the resource is temporarily unavailable." + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + post: + tags: + - "echo service" + - "echo rpc" + summary: "Summary: Echo rpc" + description: "Description Echo" + operationId: "Echo2" + parameters: + - in: "body" + name: "body" + required: true + schema: + type: "string" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/subStringMessage" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + 503: + description: "Returned when the resource is temporarily unavailable." + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + /v2/example/empty: + get: + tags: + - "camelCaseServiceName" + summary: "Create a new ABitOfEverything" + description: "This API creates a new ABitOfEverything" + operationId: "Empty" + parameters: [] + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v2/example/errorwithdetails: + get: + tags: + - "ABitOfEverythingService" + operationId: "ErrorWithDetails" + parameters: [] + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v2/example/postwithemptybody/{name}: + post: + tags: + - "ABitOfEverythingService" + operationId: "PostWithEmptyBody" + parameters: + - name: "name" + in: "path" + required: true + type: "string" + x-exportParamName: "Name" + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbBody" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v2/example/timeout: + get: + tags: + - "ABitOfEverythingService" + operationId: "Timeout" + parameters: [] + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" + /v2/example/withbody/{id}: + post: + tags: + - "ABitOfEverythingService" + operationId: "GetMessageWithBody" + parameters: + - name: "id" + in: "path" + required: true + type: "string" + x-exportParamName: "Id" + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbBody" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/protobufEmpty" + 403: + description: "Returned when the user does not have permission to access\ + \ the resource." + 404: + description: "Returned when the resource does not exist." + 418: + description: "I'm a teapot." + schema: + $ref: "#/definitions/examplepbNumericEnum" +securityDefinitions: + ApiKeyAuth: + type: "apiKey" + name: "X-API-Key" + in: "header" + BasicAuth: + type: "basic" + OAuth2: + type: "oauth2" + authorizationUrl: "https://example.com/oauth/authorize" + tokenUrl: "https://example.com/oauth/token" + flow: "accessCode" + scopes: + admin: "Grants read and write access to administrative information" + read: "Grants read access" + write: "Grants write access" +definitions: + ABitOfEverythingNested: + type: "object" + properties: + name: + type: "string" + description: "name is nested field." + amount: + type: "integer" + format: "int64" + ok: + $ref: "#/definitions/NestedDeepEnum" + description: "Nested is nested type." + example: + amount: 0 + name: "name" + ok: {} + MessagePathEnumNestedPathEnum: + type: "string" + enum: + - "GHI" + - "JKL" + default: "GHI" + NestedDeepEnum: + type: "string" + description: "DeepEnum is one or zero.\n\n - FALSE: FALSE is false.\n - TRUE:\ + \ TRUE is true." + enum: + - "FALSE" + - "TRUE" + default: "FALSE" + examplepbABitOfEverything: + type: "object" + required: + - "uuid" + properties: + single_nested: + $ref: "#/definitions/ABitOfEverythingNested" + uuid: + type: "string" + minLength: 1 + pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" + nested: + type: "array" + items: + $ref: "#/definitions/ABitOfEverythingNested" + float_value: + type: "number" + format: "float" + double_value: + type: "number" + format: "double" + int64_value: + type: "string" + format: "int64" + uint64_value: + type: "string" + format: "uint64" + int32_value: + type: "integer" + format: "int32" + fixed64_value: + type: "string" + format: "uint64" + fixed32_value: + type: "integer" + format: "int64" + bool_value: + type: "boolean" + format: "boolean" + string_value: + type: "string" + bytes_value: + type: "string" + format: "byte" + pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + uint32_value: + type: "integer" + format: "int64" + enum_value: + $ref: "#/definitions/examplepbNumericEnum" + path_enum_value: + $ref: "#/definitions/pathenumPathEnum" + nested_path_enum_value: + $ref: "#/definitions/MessagePathEnumNestedPathEnum" + sfixed32_value: + type: "integer" + format: "int32" + sfixed64_value: + type: "string" + format: "int64" + sint32_value: + type: "integer" + format: "int32" + sint64_value: + type: "string" + format: "int64" + repeated_string_value: + type: "array" + items: + type: "string" + oneof_empty: + $ref: "#/definitions/protobufEmpty" + oneof_string: + type: "string" + map_value: + type: "object" + additionalProperties: + $ref: "#/definitions/examplepbNumericEnum" + mapped_string_value: + type: "object" + additionalProperties: + type: "string" + mapped_nested_value: + type: "object" + additionalProperties: + $ref: "#/definitions/ABitOfEverythingNested" + nonConventionalNameValue: + type: "string" + timestamp_value: + type: "string" + format: "date-time" + repeated_enum_value: + type: "array" + title: "repeated enum value. it is comma-separated in query" + items: + $ref: "#/definitions/examplepbNumericEnum" + externalDocs: + description: "Find out more about ABitOfEverything" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + title: "A bit of everything" + description: "Intentionaly complicated message type to cover many features of\ + \ Protobuf." + example: + uint32_value: 2 + nonConventionalNameValue: "nonConventionalNameValue" + path_enum_value: {} + bool_value: true + nested_path_enum_value: {} + sfixed32_value: 7 + bytes_value: "bytes_value" + uuid: "uuid" + nested: + - amount: 0 + name: "name" + ok: {} + - amount: 0 + name: "name" + ok: {} + repeated_string_value: + - "repeated_string_value" + - "repeated_string_value" + timestamp_value: "2000-01-23T04:56:07.000+00:00" + uint64_value: "uint64_value" + fixed32_value: 5 + mapped_nested_value: + key: + amount: 0 + name: "name" + ok: {} + fixed64_value: "fixed64_value" + string_value: "string_value" + repeated_enum_value: + - null + - null + single_nested: + amount: 0 + name: "name" + ok: {} + enum_value: {} + mapped_string_value: + key: "mapped_string_value" + sint32_value: 9 + double_value: 1.4658129805029452 + int64_value: "int64_value" + map_value: + key: null + sfixed64_value: "sfixed64_value" + float_value: 6.0274563 + int32_value: 5 + sint64_value: "sint64_value" + oneof_string: "oneof_string" + oneof_empty: {} + examplepbABitOfEverythingRepeated: + type: "object" + properties: + path_repeated_float_value: + type: "array" + title: "repeated values. they are comma-separated in path" + items: + type: "number" + format: "float" + path_repeated_double_value: + type: "array" + items: + type: "number" + format: "double" + path_repeated_int64_value: + type: "array" + items: + type: "string" + format: "int64" + path_repeated_uint64_value: + type: "array" + items: + type: "string" + format: "uint64" + path_repeated_int32_value: + type: "array" + items: + type: "integer" + format: "int32" + path_repeated_fixed64_value: + type: "array" + items: + type: "string" + format: "uint64" + path_repeated_fixed32_value: + type: "array" + items: + type: "integer" + format: "int64" + path_repeated_bool_value: + type: "array" + items: + type: "boolean" + format: "boolean" + path_repeated_string_value: + type: "array" + items: + type: "string" + path_repeated_bytes_value: + type: "array" + items: + type: "string" + format: "byte" + pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + path_repeated_uint32_value: + type: "array" + items: + type: "integer" + format: "int64" + path_repeated_enum_value: + type: "array" + items: + $ref: "#/definitions/examplepbNumericEnum" + path_repeated_sfixed32_value: + type: "array" + items: + type: "integer" + format: "int32" + path_repeated_sfixed64_value: + type: "array" + items: + type: "string" + format: "int64" + path_repeated_sint32_value: + type: "array" + items: + type: "integer" + format: "int32" + path_repeated_sint64_value: + type: "array" + items: + type: "string" + format: "int64" + title: "ABitOfEverythingRepeated is used to validate repeated path parameter functionality" + example: + path_repeated_uint64_value: + - "path_repeated_uint64_value" + - "path_repeated_uint64_value" + path_repeated_sint32_value: + - 7 + - 7 + path_repeated_int32_value: + - 1 + - 1 + path_repeated_fixed64_value: + - "path_repeated_fixed64_value" + - "path_repeated_fixed64_value" + path_repeated_double_value: + - 6.027456183070403 + - 6.027456183070403 + path_repeated_sfixed64_value: + - "path_repeated_sfixed64_value" + - "path_repeated_sfixed64_value" + path_repeated_float_value: + - 0.8008282 + - 0.8008282 + path_repeated_fixed32_value: + - 5 + - 5 + path_repeated_int64_value: + - "path_repeated_int64_value" + - "path_repeated_int64_value" + path_repeated_uint32_value: + - 5 + - 5 + path_repeated_bytes_value: + - "path_repeated_bytes_value" + - "path_repeated_bytes_value" + path_repeated_sint64_value: + - "path_repeated_sint64_value" + - "path_repeated_sint64_value" + path_repeated_bool_value: + - true + - true + path_repeated_string_value: + - "path_repeated_string_value" + - "path_repeated_string_value" + path_repeated_enum_value: + - {} + - {} + path_repeated_sfixed32_value: + - 2 + - 2 + examplepbBody: + type: "object" + properties: + name: + type: "string" + examplepbNumericEnum: + type: "string" + description: "NumericEnum is one or zero.\n\n - ZERO: ZERO means 0\n - ONE: ONE\ + \ means 1" + enum: + - "ZERO" + - "ONE" + default: "ZERO" + pathenumPathEnum: + type: "string" + enum: + - "ABC" + - "DEF" + default: "ABC" + protobufEmpty: + type: "object" + title: "A generic empty message that you can re-use to avoid defining duplicated\n\ + empty messages in your APIs. A typical example is to use it as the request\n\ + or the response type of an API method. For instance:" + description: "service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n\ + \ }\n\nThe JSON representation for `Empty` is empty JSON object `{}`." + subStringMessage: + type: "object" + properties: + value: + type: "string" + example: + value: "value" +externalDocs: + description: "More about gRPC-Gateway" + url: "https://github.com/grpc-ecosystem/grpc-gateway" diff --git a/examples/clients/abe/api_client.go b/examples/clients/abe/api_client.go index bf3e21a9fb1..7afd5959416 100644 --- a/examples/clients/abe/api_client.go +++ b/examples/clients/abe/api_client.go @@ -1,32 +1,86 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "bytes" + "encoding/json" + "encoding/xml" "fmt" + "errors" + "io" + "mime/multipart" + "golang.org/x/oauth2" + "golang.org/x/net/context" + "net/http" + "net/url" + "time" + "os" "path/filepath" "reflect" + "regexp" "strings" - "net/url" - "io/ioutil" - "github.com/go-resty/resty" + "unicode/utf8" + "strconv" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) +// APIClient manages communication with the A Bit of Everything API v1.0 +// In most cases there should be only one, shared, APIClient. type APIClient struct { - config *Configuration + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + ABitOfEverythingServiceApi *ABitOfEverythingServiceApiService + CamelCaseServiceNameApi *CamelCaseServiceNameApiService + EchoRpcApi *EchoRpcApiService + EchoServiceApi *EchoServiceApiService } -func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { +type service struct { + client *APIClient +} +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.ABitOfEverythingServiceApi = (*ABitOfEverythingServiceApiService)(&c.common) + c.CamelCaseServiceNameApi = (*CamelCaseServiceNameApiService)(&c.common) + c.EchoRpcApi = (*EchoRpcApiService)(&c.common) + c.EchoServiceApi = (*EchoServiceApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } @@ -36,17 +90,20 @@ func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *APIClient) SelectHeaderAccept(accepts []string) string { - +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } + if contains(accepts, "application/json") { return "application/json" } + return strings.Join(accepts, ",") } +// contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { @@ -56,40 +113,24 @@ func contains(haystack []string, needle string) bool { return false } -func (c *APIClient) CallAPI(path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams url.Values, - formParams map[string]string, - fileName string, - fileBytes []byte) (*resty.Response, error) { - - rClient := c.prepareClient() - request := c.prepareRequest(rClient, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - switch strings.ToUpper(method) { - case "GET": - response, err := request.Get(path) - return response, err - case "POST": - response, err := request.Post(path) - return response, err - case "PUT": - response, err := request.Put(path) - return response, err - case "PATCH": - response, err := request.Patch(path) - return response, err - case "DELETE": - response, err := request.Delete(path) - return response, err - } - - return nil, fmt.Errorf("invalid method %v", method) -} - -func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) string { - delimiter := "" +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + switch collectionFormat { case "pipes": delimiter = "|" @@ -108,57 +149,287 @@ func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) return fmt.Sprintf("%v", obj) } -func (c *APIClient) prepareClient() *resty.Client { - - rClient := resty.New() - - rClient.SetDebug(c.config.Debug) - if c.config.Transport != nil { - rClient.SetTransport(c.config.Transport) - } +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} - if c.config.Timeout != nil { - rClient.SetTimeout(*c.config.Timeout) - } - rClient.SetLogger(ioutil.Discard) - return rClient +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath (path string) { + c.cfg.BasePath = path } -func (c *APIClient) prepareRequest( - rClient *resty.Client, +// prepareRequest build the request +func (c *APIClient) prepareRequest ( + ctx context.Context, + path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, - formParams map[string]string, + formParams url.Values, fileName string, - fileBytes []byte) *resty.Request { + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile("file", filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + } + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } - request := rClient.R() - request.SetBody(postBody) + // Encode the parameters. + url.RawQuery = query.Encode() - if c.config.UserAgent != "" { - request.SetHeader("User-Agent", c.config.UserAgent) + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err } - // add header parameter, if any + // add header parameters, if any if len(headerParams) > 0 { - request.SetHeaders(headerParams) + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers } - // add query parameter, if any - if len(queryParams) > 0 { - request.SetMultiValueQueryParams(queryParams) + // Override request host, if applicable + if c.cfg.Host != "" { + localVarRequest.Host = c.cfg.Host } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } - // add form parameter, if any - if len(formParams) > 0 { - request.SetFormData(formParams) + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer " + auth) + } } - if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) - request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) } - return request + + return localVarRequest, nil } + + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) (error) { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) (time.Time) { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } + expires = now.Add(lifetime) + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) (int) { + return utf8.RuneCountInString(s) +} + diff --git a/examples/clients/abe/api_response.go b/examples/clients/abe/api_response.go index ee1315f513c..6bca2b22c9b 100644 --- a/examples/clients/abe/api_response.go +++ b/examples/clients/abe/api_response.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe diff --git a/examples/clients/abe/camel_case_service_name_api.go b/examples/clients/abe/camel_case_service_name_api.go index ff49b76851b..7b9945faa63 100644 --- a/examples/clients/abe/camel_case_service_name_api.go +++ b/examples/clients/abe/camel_case_service_name_api.go @@ -1,85 +1,62 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "encoding/json" ) -type CamelCaseServiceNameApi struct { - Configuration *Configuration -} - -func NewCamelCaseServiceNameApi() *CamelCaseServiceNameApi { - configuration := NewConfiguration() - return &CamelCaseServiceNameApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -func NewCamelCaseServiceNameApiWithBasePath(basePath string) *CamelCaseServiceNameApi { - configuration := NewConfiguration() - configuration.BasePath = basePath +type CamelCaseServiceNameApiService service - return &CamelCaseServiceNameApi{ - Configuration: configuration, - } -} -/** - * Create a new ABitOfEverything - * This API creates a new ABitOfEverything - * - * @return *ProtobufEmpty - */ -func (a CamelCaseServiceNameApi) Empty() (*ProtobufEmpty, *APIResponse, error) { +/* CamelCaseServiceNameApiService Create a new ABitOfEverything + This API creates a new ABitOfEverything + * @param ctx context.Context for authentication, logging, tracing, etc. + @return ProtobufEmpty*/ +func (a *CamelCaseServiceNameApiService) Empty(ctx context.Context) (ProtobufEmpty, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ProtobufEmpty + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/empty" + localVarPath := a.client.cfg.BasePath + "/v2/example/empty" 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -87,25 +64,42 @@ func (a CamelCaseServiceNameApi) Empty() (*ProtobufEmpty, *APIResponse, error) { } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ProtobufEmpty) - 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: "Empty", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err } - if err != nil { - return successPayload, localVarAPIResponse, err + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + } + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/clients/abe/configuration.go b/examples/clients/abe/configuration.go index ccc319c34aa..0a49118427c 100644 --- a/examples/clients/abe/configuration.go +++ b/examples/clients/abe/configuration.go @@ -1,67 +1,73 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( - "encoding/base64" "net/http" - "time" ) +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKey takes an APIKey as authentication for the request + ContextAPIKey = contextKey("apikey") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} type Configuration struct { - Username string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` - APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"` - APIKey map[string]string `json:"APIKey,omitempty"` - Debug bool `json:"debug,omitempty"` - DebugFile string `json:"debugFile,omitempty"` - OAuthToken string `json:"oAuthToken,omitempty"` - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - AccessToken string `json:"accessToken,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - APIClient *APIClient - Transport *http.Transport - Timeout *time.Duration `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://localhost", DefaultHeader: make(map[string]string), - APIKey: make(map[string]string), - APIKeyPrefix: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", - APIClient: &APIClient{}, } - - cfg.APIClient.config = cfg return cfg } -func (c *Configuration) GetBasicAuthEncodedString() string { - return base64.StdEncoding.EncodeToString([]byte(c.Username + ":" + c.Password)) -} - func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} - -func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { - if c.APIKeyPrefix[APIKeyIdentifier] != "" { - return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] - } - - return c.APIKey[APIKeyIdentifier] -} +} \ No newline at end of file diff --git a/examples/clients/abe/echo_rpc_api.go b/examples/clients/abe/echo_rpc_api.go index 8afbbdd437f..644f8605b41 100644 --- a/examples/clients/abe/echo_rpc_api.go +++ b/examples/clients/abe/echo_rpc_api.go @@ -1,88 +1,65 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "encoding/json" "fmt" ) -type EchoRpcApi struct { - Configuration *Configuration -} - -func NewEchoRpcApi() *EchoRpcApi { - configuration := NewConfiguration() - return &EchoRpcApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -func NewEchoRpcApiWithBasePath(basePath string) *EchoRpcApi { - configuration := NewConfiguration() - configuration.BasePath = basePath +type EchoRpcApiService service - return &EchoRpcApi{ - Configuration: configuration, - } -} -/** - * Summary: Echo rpc - * Description Echo - * - * @param value - * @return *SubStringMessage - */ -func (a EchoRpcApi) Echo(value string) (*SubStringMessage, *APIResponse, error) { +/* EchoRpcApiService Summary: Echo rpc + Description Echo + * @param ctx context.Context for authentication, logging, tracing, etc. + @param value + @return SubStringMessage*/ +func (a *EchoRpcApiService) Echo(ctx context.Context, value string) (SubStringMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload SubStringMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/echo/{value}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/echo/{value}" localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -90,73 +67,76 @@ func (a EchoRpcApi) Echo(value string) (*SubStringMessage, *APIResponse, error) } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(SubStringMessage) - 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: "Echo", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } } - + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, localVarAPIResponse, err + return successPayload, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + } + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * Summary: Echo rpc - * Description Echo - * - * @param body - * @return *SubStringMessage - */ -func (a EchoRpcApi) Echo2(body string) (*SubStringMessage, *APIResponse, error) { +/* EchoRpcApiService Summary: Echo rpc + Description Echo + * @param ctx context.Context for authentication, logging, tracing, etc. + @param body + @return SubStringMessage*/ +func (a *EchoRpcApiService) Echo2(ctx context.Context, body string) (SubStringMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload SubStringMessage + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/echo" + localVarPath := a.client.cfg.BasePath + "/v2/example/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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -164,76 +144,85 @@ func (a EchoRpcApi) Echo2(body string) (*SubStringMessage, *APIResponse, error) } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(SubStringMessage) - 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: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } } - + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, localVarAPIResponse, err + return successPayload, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + + return successPayload, localVarHttpResponse, err } -/** - * Summary: Echo rpc - * Description Echo - * - * @param value - * @return *SubStringMessage - */ -func (a EchoRpcApi) Echo3(value string) (*SubStringMessage, *APIResponse, error) { +/* EchoRpcApiService Summary: Echo rpc + Description Echo + * @param ctx context.Context for authentication, logging, tracing, etc. + @param optional (nil or map[string]interface{}) with one or more of: + @param "value" (string) + @return SubStringMessage*/ +func (a *EchoRpcApiService) Echo3(ctx context.Context, localVarOptionals map[string]interface{}) (SubStringMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload SubStringMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/echo" + localVarPath := a.client.cfg.BasePath + "/v2/example/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] + localVarFormParams := url.Values{} + + if err := typeCheckParameter(localVarOptionals["value"], "string", "value"); err != nil { + return successPayload, nil, err } - localVarQueryParams.Add("value", a.Configuration.APIClient.ParameterToString(value, "")) + if localVarTempParam, localVarOk := localVarOptionals["value"].(string); localVarOk { + localVarQueryParams.Add("value", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -241,25 +230,42 @@ func (a EchoRpcApi) Echo3(value string) (*SubStringMessage, *APIResponse, error) } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(SubStringMessage) - 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 ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } } - + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, localVarAPIResponse, err + return successPayload, nil, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + } + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/clients/abe/echo_service_api.go b/examples/clients/abe/echo_service_api.go index 568177715d2..b12f09c4834 100644 --- a/examples/clients/abe/echo_service_api.go +++ b/examples/clients/abe/echo_service_api.go @@ -1,88 +1,65 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "encoding/json" "fmt" ) -type EchoServiceApi struct { - Configuration *Configuration -} - -func NewEchoServiceApi() *EchoServiceApi { - configuration := NewConfiguration() - return &EchoServiceApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -func NewEchoServiceApiWithBasePath(basePath string) *EchoServiceApi { - configuration := NewConfiguration() - configuration.BasePath = basePath +type EchoServiceApiService service - return &EchoServiceApi{ - Configuration: configuration, - } -} -/** - * Summary: Echo rpc - * Description Echo - * - * @param value - * @return *SubStringMessage - */ -func (a EchoServiceApi) Echo(value string) (*SubStringMessage, *APIResponse, error) { +/* EchoServiceApiService Summary: Echo rpc + Description Echo + * @param ctx context.Context for authentication, logging, tracing, etc. + @param value + @return SubStringMessage*/ +func (a *EchoServiceApiService) Echo(ctx context.Context, value string) (SubStringMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload SubStringMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/a_bit_of_everything/echo/{value}" + localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/echo/{value}" localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -90,73 +67,76 @@ func (a EchoServiceApi) Echo(value string) (*SubStringMessage, *APIResponse, err } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(SubStringMessage) - 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: "Echo", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } } - + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, localVarAPIResponse, err + return successPayload, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + } + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * Summary: Echo rpc - * Description Echo - * - * @param body - * @return *SubStringMessage - */ -func (a EchoServiceApi) Echo2(body string) (*SubStringMessage, *APIResponse, error) { +/* EchoServiceApiService Summary: Echo rpc + Description Echo + * @param ctx context.Context for authentication, logging, tracing, etc. + @param body + @return SubStringMessage*/ +func (a *EchoServiceApiService) Echo2(ctx context.Context, body string) (SubStringMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload SubStringMessage + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/echo" + localVarPath := a.client.cfg.BasePath + "/v2/example/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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -164,76 +144,85 @@ func (a EchoServiceApi) Echo2(body string) (*SubStringMessage, *APIResponse, err } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(SubStringMessage) - 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: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } } - + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, localVarAPIResponse, err + return successPayload, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + + return successPayload, localVarHttpResponse, err } -/** - * Summary: Echo rpc - * Description Echo - * - * @param value - * @return *SubStringMessage - */ -func (a EchoServiceApi) Echo3(value string) (*SubStringMessage, *APIResponse, error) { +/* EchoServiceApiService Summary: Echo rpc + Description Echo + * @param ctx context.Context for authentication, logging, tracing, etc. + @param optional (nil or map[string]interface{}) with one or more of: + @param "value" (string) + @return SubStringMessage*/ +func (a *EchoServiceApiService) Echo3(ctx context.Context, localVarOptionals map[string]interface{}) (SubStringMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload SubStringMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v2/example/echo" + localVarPath := a.client.cfg.BasePath + "/v2/example/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] + localVarFormParams := url.Values{} + + if err := typeCheckParameter(localVarOptionals["value"], "string", "value"); err != nil { + return successPayload, nil, err } - localVarQueryParams.Add("value", a.Configuration.APIClient.ParameterToString(value, "")) + if localVarTempParam, localVarOk := localVarOptionals["value"].(string); localVarOk { + localVarQueryParams.Add("value", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } + // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", @@ -241,25 +230,42 @@ func (a EchoServiceApi) Echo3(value string) (*SubStringMessage, *APIResponse, er } // set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(SubStringMessage) - 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 ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["X-API-Key"] = key + } } - + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, localVarAPIResponse, err + return successPayload, nil, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + } + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/clients/abe/examplepb_a_bit_of_everything.go b/examples/clients/abe/examplepb_a_bit_of_everything.go index f413637e1ca..06fb7ac0e9c 100644 --- a/examples/clients/abe/examplepb_a_bit_of_everything.go +++ b/examples/clients/abe/examplepb_a_bit_of_everything.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe @@ -17,7 +17,7 @@ import ( // Intentionaly complicated message type to cover many features of Protobuf. type ExamplepbABitOfEverything struct { - SingleNested ABitOfEverythingNested `json:"single_nested,omitempty"` + SingleNested *ABitOfEverythingNested `json:"single_nested,omitempty"` Uuid string `json:"uuid"` @@ -45,11 +45,11 @@ type ExamplepbABitOfEverything struct { Uint32Value int64 `json:"uint32_value,omitempty"` - EnumValue ExamplepbNumericEnum `json:"enum_value,omitempty"` + EnumValue *ExamplepbNumericEnum `json:"enum_value,omitempty"` - PathEnumValue PathenumPathEnum `json:"path_enum_value,omitempty"` + PathEnumValue *PathenumPathEnum `json:"path_enum_value,omitempty"` - NestedPathEnumValue MessagePathEnumNestedPathEnum `json:"nested_path_enum_value,omitempty"` + NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nested_path_enum_value,omitempty"` Sfixed32Value int32 `json:"sfixed32_value,omitempty"` @@ -61,7 +61,7 @@ type ExamplepbABitOfEverything struct { RepeatedStringValue []string `json:"repeated_string_value,omitempty"` - OneofEmpty ProtobufEmpty `json:"oneof_empty,omitempty"` + OneofEmpty *ProtobufEmpty `json:"oneof_empty,omitempty"` OneofString string `json:"oneof_string,omitempty"` diff --git a/examples/clients/abe/examplepb_a_bit_of_everything_repeated.go b/examples/clients/abe/examplepb_a_bit_of_everything_repeated.go index 35f588ccf3d..a50fdaea529 100644 --- a/examples/clients/abe/examplepb_a_bit_of_everything_repeated.go +++ b/examples/clients/abe/examplepb_a_bit_of_everything_repeated.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe diff --git a/examples/clients/abe/examplepb_body.go b/examples/clients/abe/examplepb_body.go index 13f4c2dc1e1..be2b5134c1c 100644 --- a/examples/clients/abe/examplepb_body.go +++ b/examples/clients/abe/examplepb_body.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe diff --git a/examples/clients/abe/examplepb_numeric_enum.go b/examples/clients/abe/examplepb_numeric_enum.go index e953bbe34e8..7017046ca38 100644 --- a/examples/clients/abe/examplepb_numeric_enum.go +++ b/examples/clients/abe/examplepb_numeric_enum.go @@ -1,15 +1,19 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe +// ExamplepbNumericEnum : NumericEnum is one or zero. - ZERO: ZERO means 0 - ONE: ONE means 1 +type examplepbNumericEnum string -// NumericEnum is one or zero. - ZERO: ZERO means 0 - ONE: ONE means 1 -type ExamplepbNumericEnum struct { -} +// List of examplepbNumericEnum +const ( + ZERO ExamplepbNumericEnum = "ZERO" + ONE ExamplepbNumericEnum = "ONE" +) diff --git a/examples/clients/abe/message_path_enum_nested_path_enum.go b/examples/clients/abe/message_path_enum_nested_path_enum.go index a6d9a579f6c..54d13001a67 100644 --- a/examples/clients/abe/message_path_enum_nested_path_enum.go +++ b/examples/clients/abe/message_path_enum_nested_path_enum.go @@ -1,14 +1,19 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe -type MessagePathEnumNestedPathEnum struct { -} +type MessagePathEnumNestedPathEnum string + +// List of MessagePathEnumNestedPathEnum +const ( + GHI MessagePathEnumNestedPathEnum = "GHI" + JKL MessagePathEnumNestedPathEnum = "JKL" +) diff --git a/examples/clients/abe/nested_deep_enum.go b/examples/clients/abe/nested_deep_enum.go index e5fc17d50a4..3abafc956b4 100644 --- a/examples/clients/abe/nested_deep_enum.go +++ b/examples/clients/abe/nested_deep_enum.go @@ -1,15 +1,19 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe +// NestedDeepEnum : DeepEnum is one or zero. - FALSE: FALSE is false. - TRUE: TRUE is true. +type NestedDeepEnum string -// DeepEnum is one or zero. - FALSE: FALSE is false. - TRUE: TRUE is true. -type NestedDeepEnum struct { -} +// List of NestedDeepEnum +const ( + FALSE NestedDeepEnum = "FALSE" + TRUE NestedDeepEnum = "TRUE" +) diff --git a/examples/clients/abe/pathenum_path_enum.go b/examples/clients/abe/pathenum_path_enum.go index 76e4f87650d..a26b1e0ff3b 100644 --- a/examples/clients/abe/pathenum_path_enum.go +++ b/examples/clients/abe/pathenum_path_enum.go @@ -1,14 +1,19 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe -type PathenumPathEnum struct { -} +type pathenumPathEnum string + +// List of pathenumPathEnum +const ( + ABC PathenumPathEnum = "ABC" + DEF PathenumPathEnum = "DEF" +) diff --git a/examples/clients/abe/protobuf_empty.go b/examples/clients/abe/protobuf_empty.go index 97c7bf612b8..b85eb6131ac 100644 --- a/examples/clients/abe/protobuf_empty.go +++ b/examples/clients/abe/protobuf_empty.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe diff --git a/examples/clients/abe/sub_string_message.go b/examples/clients/abe/sub_string_message.go index 2a0874fc5fa..4f89db34080 100644 --- a/examples/clients/abe/sub_string_message.go +++ b/examples/clients/abe/sub_string_message.go @@ -1,11 +1,11 @@ -/* +/* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: 1.0 + * API version: 1.0 * Contact: none@example.com - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe diff --git a/examples/clients/echo/.swagger-codegen/VERSION b/examples/clients/echo/.swagger-codegen/VERSION new file mode 100644 index 00000000000..717311e32e3 --- /dev/null +++ b/examples/clients/echo/.swagger-codegen/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/examples/clients/echo/api/swagger.yaml b/examples/clients/echo/api/swagger.yaml new file mode 100644 index 00000000000..4dce100130d --- /dev/null +++ b/examples/clients/echo/api/swagger.yaml @@ -0,0 +1,407 @@ +--- +swagger: "2.0" +info: + description: "Echo Service API consists of a single service which returns\na message." + version: "version not set" + title: "Echo Service" +schemes: +- "http" +- "https" +consumes: +- "application/json" +produces: +- "application/json" +paths: + /v1/example/echo/{id}: + post: + tags: + - "EchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo" + parameters: + - name: "id" + in: "path" + description: "Id represents the message identifier." + required: true + type: "string" + x-exportParamName: "Id" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" + /v1/example/echo/{id}/{num}: + get: + tags: + - "EchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo2" + parameters: + - name: "id" + in: "path" + description: "Id represents the message identifier." + required: true + type: "string" + x-exportParamName: "Id" + - name: "num" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "line_num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "LineNum" + - name: "lang" + in: "query" + required: false + type: "string" + x-exportParamName: "Lang" + - name: "status.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "StatusProgress" + - name: "status.note" + in: "query" + required: false + type: "string" + x-exportParamName: "StatusNote" + - name: "en" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "En" + - name: "no.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "NoProgress" + - name: "no.note" + in: "query" + required: false + type: "string" + x-exportParamName: "NoNote" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" + /v1/example/echo/{id}/{num}/{lang}: + get: + tags: + - "EchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo3" + parameters: + - name: "id" + in: "path" + description: "Id represents the message identifier." + required: true + type: "string" + x-exportParamName: "Id" + - name: "num" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "lang" + in: "path" + required: true + type: "string" + x-exportParamName: "Lang" + - name: "line_num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "LineNum" + - name: "status.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "StatusProgress" + - name: "status.note" + in: "query" + required: false + type: "string" + x-exportParamName: "StatusNote" + - name: "en" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "En" + - name: "no.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "NoProgress" + - name: "no.note" + in: "query" + required: false + type: "string" + x-exportParamName: "NoNote" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" + /v1/example/echo1/{id}/{line_num}/{status.note}: + get: + tags: + - "EchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo4" + parameters: + - name: "id" + in: "path" + description: "Id represents the message identifier." + required: true + type: "string" + x-exportParamName: "Id" + - name: "line_num" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "LineNum" + - name: "status.note" + in: "path" + required: true + type: "string" + x-exportParamName: "StatusNote" + - name: "num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "lang" + in: "query" + required: false + type: "string" + x-exportParamName: "Lang" + - name: "status.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "StatusProgress" + - name: "en" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "En" + - name: "no.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "NoProgress" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" + /v1/example/echo2/{no.note}: + get: + tags: + - "EchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo5" + parameters: + - name: "no.note" + in: "path" + required: true + type: "string" + x-exportParamName: "NoNote" + - name: "id" + in: "query" + description: "Id represents the message identifier." + required: false + type: "string" + x-exportParamName: "Id" + - name: "num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "line_num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "LineNum" + - name: "lang" + in: "query" + required: false + type: "string" + x-exportParamName: "Lang" + - name: "status.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "StatusProgress" + - name: "en" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "En" + - name: "no.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "NoProgress" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" + /v1/example/echo_body: + post: + tags: + - "EchoService" + summary: "EchoBody method receives a simple message and returns it." + operationId: "EchoBody" + parameters: + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbSimpleMessage" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" + /v1/example/echo_delete: + delete: + tags: + - "EchoService" + summary: "EchoDelete method receives a simple message and returns it." + operationId: "EchoDelete" + parameters: + - name: "id" + in: "query" + description: "Id represents the message identifier." + required: false + type: "string" + x-exportParamName: "Id" + - name: "num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "line_num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "LineNum" + - name: "lang" + in: "query" + required: false + type: "string" + x-exportParamName: "Lang" + - name: "status.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "StatusProgress" + - name: "status.note" + in: "query" + required: false + type: "string" + x-exportParamName: "StatusNote" + - name: "en" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "En" + - name: "no.progress" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "NoProgress" + - name: "no.note" + in: "query" + required: false + type: "string" + x-exportParamName: "NoNote" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbSimpleMessage" +definitions: + examplepbEmbedded: + type: "object" + properties: + progress: + type: "string" + format: "int64" + note: + type: "string" + description: "Embedded represents a message embedded in SimpleMessage." + example: + note: "note" + progress: "progress" + examplepbSimpleMessage: + type: "object" + properties: + id: + type: "string" + description: "Id represents the message identifier." + 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." + example: + no: + note: "note" + progress: "progress" + line_num: "line_num" + num: "num" + en: "en" + id: "id" + lang: "lang" + status: + note: "note" + progress: "progress" diff --git a/examples/clients/echo/api_client.go b/examples/clients/echo/api_client.go index 7a517148026..e8b8080df72 100644 --- a/examples/clients/echo/api_client.go +++ b/examples/clients/echo/api_client.go @@ -1,32 +1,79 @@ -/* +/* * 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( "bytes" + "encoding/json" + "encoding/xml" "fmt" + "errors" + "io" + "mime/multipart" + "golang.org/x/oauth2" + "golang.org/x/net/context" + "net/http" + "net/url" + "time" + "os" "path/filepath" "reflect" + "regexp" "strings" - "net/url" - "io/ioutil" - "github.com/go-resty/resty" + "unicode/utf8" + "strconv" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) +// APIClient manages communication with the Echo Service API vversion not set +// In most cases there should be only one, shared, APIClient. type APIClient struct { - config *Configuration + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + EchoServiceApi *EchoServiceApiService } -func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { +type service struct { + client *APIClient +} +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.EchoServiceApi = (*EchoServiceApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } @@ -36,17 +83,20 @@ func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *APIClient) SelectHeaderAccept(accepts []string) string { - +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } + if contains(accepts, "application/json") { return "application/json" } + return strings.Join(accepts, ",") } +// contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { @@ -56,40 +106,24 @@ func contains(haystack []string, needle string) bool { return false } -func (c *APIClient) CallAPI(path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams url.Values, - formParams map[string]string, - fileName string, - fileBytes []byte) (*resty.Response, error) { - - rClient := c.prepareClient() - request := c.prepareRequest(rClient, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - switch strings.ToUpper(method) { - case "GET": - response, err := request.Get(path) - return response, err - case "POST": - response, err := request.Post(path) - return response, err - case "PUT": - response, err := request.Put(path) - return response, err - case "PATCH": - response, err := request.Patch(path) - return response, err - case "DELETE": - response, err := request.Delete(path) - return response, err - } - - return nil, fmt.Errorf("invalid method %v", method) -} - -func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) string { - delimiter := "" +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + switch collectionFormat { case "pipes": delimiter = "|" @@ -108,57 +142,287 @@ func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) return fmt.Sprintf("%v", obj) } -func (c *APIClient) prepareClient() *resty.Client { - - rClient := resty.New() - - rClient.SetDebug(c.config.Debug) - if c.config.Transport != nil { - rClient.SetTransport(c.config.Transport) - } +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} - if c.config.Timeout != nil { - rClient.SetTimeout(*c.config.Timeout) - } - rClient.SetLogger(ioutil.Discard) - return rClient +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath (path string) { + c.cfg.BasePath = path } -func (c *APIClient) prepareRequest( - rClient *resty.Client, +// prepareRequest build the request +func (c *APIClient) prepareRequest ( + ctx context.Context, + path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, - formParams map[string]string, + formParams url.Values, fileName string, - fileBytes []byte) *resty.Request { + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile("file", filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + } + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } - request := rClient.R() - request.SetBody(postBody) + // Encode the parameters. + url.RawQuery = query.Encode() - if c.config.UserAgent != "" { - request.SetHeader("User-Agent", c.config.UserAgent) + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err } - // add header parameter, if any + // add header parameters, if any if len(headerParams) > 0 { - request.SetHeaders(headerParams) + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers } - // add query parameter, if any - if len(queryParams) > 0 { - request.SetMultiValueQueryParams(queryParams) + // Override request host, if applicable + if c.cfg.Host != "" { + localVarRequest.Host = c.cfg.Host } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } - // add form parameter, if any - if len(formParams) > 0 { - request.SetFormData(formParams) + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer " + auth) + } } - if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) - request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) } - return request + + return localVarRequest, nil } + + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) (error) { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) (time.Time) { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } + expires = now.Add(lifetime) + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) (int) { + return utf8.RuneCountInString(s) +} + diff --git a/examples/clients/echo/api_response.go b/examples/clients/echo/api_response.go index 8b0d07c4a13..a61998c91d4 100644 --- a/examples/clients/echo/api_response.go +++ b/examples/clients/echo/api_response.go @@ -1,11 +1,10 @@ -/* +/* * 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo diff --git a/examples/clients/echo/configuration.go b/examples/clients/echo/configuration.go index 9a75a30aeec..8158467710f 100644 --- a/examples/clients/echo/configuration.go +++ b/examples/clients/echo/configuration.go @@ -1,67 +1,72 @@ -/* +/* * 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( - "encoding/base64" "net/http" - "time" ) +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKey takes an APIKey as authentication for the request + ContextAPIKey = contextKey("apikey") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} type Configuration struct { - Username string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` - APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"` - APIKey map[string]string `json:"APIKey,omitempty"` - Debug bool `json:"debug,omitempty"` - DebugFile string `json:"debugFile,omitempty"` - OAuthToken string `json:"oAuthToken,omitempty"` - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - AccessToken string `json:"accessToken,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - APIClient *APIClient - Transport *http.Transport - Timeout *time.Duration `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://localhost", DefaultHeader: make(map[string]string), - APIKey: make(map[string]string), - APIKeyPrefix: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", - APIClient: &APIClient{}, } - - cfg.APIClient.config = cfg return cfg } -func (c *Configuration) GetBasicAuthEncodedString() string { - return base64.StdEncoding.EncodeToString([]byte(c.Username + ":" + c.Password)) -} - func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} - -func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { - if c.APIKeyPrefix[APIKeyIdentifier] != "" { - return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] - } - - return c.APIKey[APIKeyIdentifier] -} +} \ No newline at end of file diff --git a/examples/clients/echo/echo_service_api.go b/examples/clients/echo/echo_service_api.go index 6ae7cf85a32..69aecf8e862 100644 --- a/examples/clients/echo/echo_service_api.go +++ b/examples/clients/echo/echo_service_api.go @@ -1,541 +1,734 @@ -/* +/* * 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "encoding/json" "fmt" ) -type EchoServiceApi struct { - Configuration *Configuration -} - -func NewEchoServiceApi() *EchoServiceApi { - configuration := NewConfiguration() - return &EchoServiceApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -func NewEchoServiceApiWithBasePath(basePath string) *EchoServiceApi { - configuration := NewConfiguration() - configuration.BasePath = basePath +type EchoServiceApiService service - return &EchoServiceApi{ - Configuration: configuration, - } -} -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id Id represents the message identifier. - * @return *ExamplepbSimpleMessage - */ -func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, error) { +/* EchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id Id represents the message identifier. + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) Echo(ctx context.Context, id string) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := 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) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @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) Echo2(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +/* EchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id Id represents the message identifier. + @param num + @param optional (nil or map[string]interface{}) with one or more of: + @param "lineNum" (string) + @param "lang" (string) + @param "statusProgress" (string) + @param "statusNote" (string) + @param "en" (string) + @param "noProgress" (string) + @param "noNote" (string) + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) Echo2(ctx context.Context, id string, num string, localVarOptionals map[string]interface{}) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}/{num}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -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("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, "")) + localVarFormParams := url.Values{} + + if err := typeCheckParameter(localVarOptionals["lineNum"], "string", "lineNum"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["lang"], "string", "lang"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusProgress"], "string", "statusProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusNote"], "string", "statusNote"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["en"], "string", "en"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noProgress"], "string", "noProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noNote"], "string", "noNote"); err != nil { + return successPayload, nil, err + } + if localVarTempParam, localVarOk := localVarOptionals["lineNum"].(string); localVarOk { + localVarQueryParams.Add("line_num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["lang"].(string); localVarOk { + localVarQueryParams.Add("lang", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusProgress"].(string); localVarOk { + localVarQueryParams.Add("status.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusNote"].(string); localVarOk { + localVarQueryParams.Add("status.note", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["en"].(string); localVarOk { + localVarQueryParams.Add("en", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noProgress"].(string); localVarOk { + localVarQueryParams.Add("no.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noNote"].(string); localVarOk { + localVarQueryParams.Add("no.note", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := 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) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id Id represents the message identifier. - * @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) { +/* EchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id Id represents the message identifier. + @param num + @param lang + @param optional (nil or map[string]interface{}) with one or more of: + @param "lineNum" (string) + @param "statusProgress" (string) + @param "statusNote" (string) + @param "en" (string) + @param "noProgress" (string) + @param "noNote" (string) + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) Echo3(ctx context.Context, id string, num string, lang string, localVarOptionals map[string]interface{}) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}/{lang}" + localVarPath := a.client.cfg.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, "")) + localVarFormParams := url.Values{} + if err := typeCheckParameter(localVarOptionals["lineNum"], "string", "lineNum"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusProgress"], "string", "statusProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusNote"], "string", "statusNote"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["en"], "string", "en"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noProgress"], "string", "noProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noNote"], "string", "noNote"); err != nil { + return successPayload, nil, err + } + + if localVarTempParam, localVarOk := localVarOptionals["lineNum"].(string); localVarOk { + localVarQueryParams.Add("line_num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusProgress"].(string); localVarOk { + localVarQueryParams.Add("status.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusNote"].(string); localVarOk { + localVarQueryParams.Add("status.note", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["en"].(string); localVarOk { + localVarQueryParams.Add("en", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noProgress"].(string); localVarOk { + localVarQueryParams.Add("no.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noNote"].(string); localVarOk { + localVarQueryParams.Add("no.note", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := 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) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - 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() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id Id represents the message identifier. - * @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) { +/* EchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id Id represents the message identifier. + @param lineNum + @param statusNote + @param optional (nil or map[string]interface{}) with one or more of: + @param "num" (string) + @param "lang" (string) + @param "statusProgress" (string) + @param "en" (string) + @param "noProgress" (string) + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) Echo4(ctx context.Context, id string, lineNum string, statusNote string, localVarOptionals map[string]interface{}) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo1/{id}/{line_num}/{status.note}" + localVarPath := a.client.cfg.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, "")) + localVarFormParams := url.Values{} + if err := typeCheckParameter(localVarOptionals["num"], "string", "num"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["lang"], "string", "lang"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusProgress"], "string", "statusProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["en"], "string", "en"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noProgress"], "string", "noProgress"); err != nil { + return successPayload, nil, err + } + + if localVarTempParam, localVarOk := localVarOptionals["num"].(string); localVarOk { + localVarQueryParams.Add("num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["lang"].(string); localVarOk { + localVarQueryParams.Add("lang", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusProgress"].(string); localVarOk { + localVarQueryParams.Add("status.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["en"].(string); localVarOk { + localVarQueryParams.Add("en", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noProgress"].(string); localVarOk { + localVarQueryParams.Add("no.progress", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := 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) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - 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() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, 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) { +/* EchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param noNote + @param optional (nil or map[string]interface{}) with one or more of: + @param "id" (string) Id represents the message identifier. + @param "num" (string) + @param "lineNum" (string) + @param "lang" (string) + @param "statusProgress" (string) + @param "en" (string) + @param "noProgress" (string) + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) Echo5(ctx context.Context, noNote string, localVarOptionals map[string]interface{}) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo2/{no.note}" + localVarPath := a.client.cfg.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, "")) + localVarFormParams := url.Values{} + if err := typeCheckParameter(localVarOptionals["id"], "string", "id"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["num"], "string", "num"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["lineNum"], "string", "lineNum"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["lang"], "string", "lang"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusProgress"], "string", "statusProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["en"], "string", "en"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noProgress"], "string", "noProgress"); err != nil { + return successPayload, nil, err + } + + if localVarTempParam, localVarOk := localVarOptionals["id"].(string); localVarOk { + localVarQueryParams.Add("id", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["num"].(string); localVarOk { + localVarQueryParams.Add("num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["lineNum"].(string); localVarOk { + localVarQueryParams.Add("line_num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["lang"].(string); localVarOk { + localVarQueryParams.Add("lang", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusProgress"].(string); localVarOk { + localVarQueryParams.Add("status.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["en"].(string); localVarOk { + localVarQueryParams.Add("en", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noProgress"].(string); localVarOk { + localVarQueryParams.Add("no.progress", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := 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) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - 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() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * EchoBody method receives a simple message and returns it. - * - * @param body - * @return *ExamplepbSimpleMessage - */ -func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { +/* EchoServiceApiService EchoBody method receives a simple message and returns it. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param body + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) EchoBody(ctx context.Context, body ExamplepbSimpleMessage) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo_body" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo_body" 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(ExamplepbSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "EchoBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * EchoDelete method receives a simple message and returns it. - * - * @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) { +/* EchoServiceApiService EchoDelete method receives a simple message and returns it. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param optional (nil or map[string]interface{}) with one or more of: + @param "id" (string) Id represents the message identifier. + @param "num" (string) + @param "lineNum" (string) + @param "lang" (string) + @param "statusProgress" (string) + @param "statusNote" (string) + @param "en" (string) + @param "noProgress" (string) + @param "noNote" (string) + @return ExamplepbSimpleMessage*/ +func (a *EchoServiceApiService) EchoDelete(ctx context.Context, localVarOptionals map[string]interface{}) (ExamplepbSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo_delete" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo_delete" 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("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, "")) + localVarFormParams := url.Values{} + + if err := typeCheckParameter(localVarOptionals["id"], "string", "id"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["num"], "string", "num"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["lineNum"], "string", "lineNum"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["lang"], "string", "lang"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusProgress"], "string", "statusProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["statusNote"], "string", "statusNote"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["en"], "string", "en"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noProgress"], "string", "noProgress"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["noNote"], "string", "noNote"); err != nil { + return successPayload, nil, err + } + if localVarTempParam, localVarOk := localVarOptionals["id"].(string); localVarOk { + localVarQueryParams.Add("id", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["num"].(string); localVarOk { + localVarQueryParams.Add("num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["lineNum"].(string); localVarOk { + localVarQueryParams.Add("line_num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["lang"].(string); localVarOk { + localVarQueryParams.Add("lang", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusProgress"].(string); localVarOk { + localVarQueryParams.Add("status.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["statusNote"].(string); localVarOk { + localVarQueryParams.Add("status.note", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["en"].(string); localVarOk { + localVarQueryParams.Add("en", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noProgress"].(string); localVarOk { + localVarQueryParams.Add("no.progress", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["noNote"].(string); localVarOk { + localVarQueryParams.Add("no.note", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := 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) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "EchoDelete", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/clients/echo/examplepb_embedded.go b/examples/clients/echo/examplepb_embedded.go index 4b5fe265ac9..95dc0076e35 100644 --- a/examples/clients/echo/examplepb_embedded.go +++ b/examples/clients/echo/examplepb_embedded.go @@ -1,11 +1,10 @@ -/* +/* * 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo diff --git a/examples/clients/echo/examplepb_simple_message.go b/examples/clients/echo/examplepb_simple_message.go index 366a6876665..667fadaa40d 100644 --- a/examples/clients/echo/examplepb_simple_message.go +++ b/examples/clients/echo/examplepb_simple_message.go @@ -1,11 +1,10 @@ -/* +/* * 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo @@ -22,9 +21,9 @@ type ExamplepbSimpleMessage struct { Lang string `json:"lang,omitempty"` - Status ExamplepbEmbedded `json:"status,omitempty"` + Status *ExamplepbEmbedded `json:"status,omitempty"` En string `json:"en,omitempty"` - No ExamplepbEmbedded `json:"no,omitempty"` + No *ExamplepbEmbedded `json:"no,omitempty"` } diff --git a/examples/clients/responsebody/.swagger-codegen/VERSION b/examples/clients/responsebody/.swagger-codegen/VERSION new file mode 100644 index 00000000000..717311e32e3 --- /dev/null +++ b/examples/clients/responsebody/.swagger-codegen/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/examples/clients/responsebody/api/swagger.yaml b/examples/clients/responsebody/api/swagger.yaml new file mode 100644 index 00000000000..f743e83475a --- /dev/null +++ b/examples/clients/responsebody/api/swagger.yaml @@ -0,0 +1,42 @@ +--- +swagger: "2.0" +info: + version: "version not set" + title: "examples/proto/examplepb/response_body_service.proto" +schemes: +- "http" +- "https" +consumes: +- "application/json" +produces: +- "application/json" +paths: + /responsebody/{data}: + get: + tags: + - "ResponseBodyService" + operationId: "GetResponseBody" + parameters: + - name: "data" + in: "path" + required: true + type: "string" + x-exportParamName: "Data" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbResponseBodyOutResponse" +definitions: + examplepbResponseBodyOut: + type: "object" + properties: + response: + $ref: "#/definitions/examplepbResponseBodyOutResponse" + examplepbResponseBodyOutResponse: + type: "object" + properties: + data: + type: "string" + example: + data: "data" diff --git a/examples/clients/responsebody/api_client.go b/examples/clients/responsebody/api_client.go index 1f7354b61dc..78efe43f8e1 100644 --- a/examples/clients/responsebody/api_client.go +++ b/examples/clients/responsebody/api_client.go @@ -1,32 +1,79 @@ -/* +/* * examples/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( "bytes" + "encoding/json" + "encoding/xml" "fmt" + "errors" + "io" + "mime/multipart" + "golang.org/x/oauth2" + "golang.org/x/net/context" + "net/http" + "net/url" + "time" + "os" "path/filepath" "reflect" + "regexp" "strings" - "net/url" - "io/ioutil" - "github.com/go-resty/resty" + "unicode/utf8" + "strconv" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) +// APIClient manages communication with the examples/proto/examplepb/response_body_service.proto API vversion not set +// In most cases there should be only one, shared, APIClient. type APIClient struct { - config *Configuration + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + ResponseBodyServiceApi *ResponseBodyServiceApiService } -func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { +type service struct { + client *APIClient +} +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.ResponseBodyServiceApi = (*ResponseBodyServiceApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } @@ -36,17 +83,20 @@ func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *APIClient) SelectHeaderAccept(accepts []string) string { - +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } + if contains(accepts, "application/json") { return "application/json" } + return strings.Join(accepts, ",") } +// contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { @@ -56,40 +106,24 @@ func contains(haystack []string, needle string) bool { return false } -func (c *APIClient) CallAPI(path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams url.Values, - formParams map[string]string, - fileName string, - fileBytes []byte) (*resty.Response, error) { - - rClient := c.prepareClient() - request := c.prepareRequest(rClient, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - switch strings.ToUpper(method) { - case "GET": - response, err := request.Get(path) - return response, err - case "POST": - response, err := request.Post(path) - return response, err - case "PUT": - response, err := request.Put(path) - return response, err - case "PATCH": - response, err := request.Patch(path) - return response, err - case "DELETE": - response, err := request.Delete(path) - return response, err - } - - return nil, fmt.Errorf("invalid method %v", method) -} - -func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) string { - delimiter := "" +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + switch collectionFormat { case "pipes": delimiter = "|" @@ -108,57 +142,287 @@ func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) return fmt.Sprintf("%v", obj) } -func (c *APIClient) prepareClient() *resty.Client { - - rClient := resty.New() - - rClient.SetDebug(c.config.Debug) - if c.config.Transport != nil { - rClient.SetTransport(c.config.Transport) - } +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} - if c.config.Timeout != nil { - rClient.SetTimeout(*c.config.Timeout) - } - rClient.SetLogger(ioutil.Discard) - return rClient +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath (path string) { + c.cfg.BasePath = path } -func (c *APIClient) prepareRequest( - rClient *resty.Client, +// prepareRequest build the request +func (c *APIClient) prepareRequest ( + ctx context.Context, + path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, - formParams map[string]string, + formParams url.Values, fileName string, - fileBytes []byte) *resty.Request { + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile("file", filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + } + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } - request := rClient.R() - request.SetBody(postBody) + // Encode the parameters. + url.RawQuery = query.Encode() - if c.config.UserAgent != "" { - request.SetHeader("User-Agent", c.config.UserAgent) + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err } - // add header parameter, if any + // add header parameters, if any if len(headerParams) > 0 { - request.SetHeaders(headerParams) + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers } - // add query parameter, if any - if len(queryParams) > 0 { - request.SetMultiValueQueryParams(queryParams) + // Override request host, if applicable + if c.cfg.Host != "" { + localVarRequest.Host = c.cfg.Host } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } - // add form parameter, if any - if len(formParams) > 0 { - request.SetFormData(formParams) + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer " + auth) + } } - if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) - request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) } - return request + + return localVarRequest, nil } + + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) (error) { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) (time.Time) { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } + expires = now.Add(lifetime) + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) (int) { + return utf8.RuneCountInString(s) +} + diff --git a/examples/clients/responsebody/api_response.go b/examples/clients/responsebody/api_response.go index 225d12176b3..e72bf3ad6db 100644 --- a/examples/clients/responsebody/api_response.go +++ b/examples/clients/responsebody/api_response.go @@ -1,11 +1,10 @@ -/* +/* * examples/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody diff --git a/examples/clients/responsebody/configuration.go b/examples/clients/responsebody/configuration.go index 0ffa917b424..1824656bad1 100644 --- a/examples/clients/responsebody/configuration.go +++ b/examples/clients/responsebody/configuration.go @@ -1,67 +1,72 @@ -/* +/* * examples/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( - "encoding/base64" "net/http" - "time" ) +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKey takes an APIKey as authentication for the request + ContextAPIKey = contextKey("apikey") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} type Configuration struct { - Username string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` - APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"` - APIKey map[string]string `json:"APIKey,omitempty"` - Debug bool `json:"debug,omitempty"` - DebugFile string `json:"debugFile,omitempty"` - OAuthToken string `json:"oAuthToken,omitempty"` - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - AccessToken string `json:"accessToken,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - APIClient *APIClient - Transport *http.Transport - Timeout *time.Duration `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://localhost", DefaultHeader: make(map[string]string), - APIKey: make(map[string]string), - APIKeyPrefix: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", - APIClient: &APIClient{}, } - - cfg.APIClient.config = cfg return cfg } -func (c *Configuration) GetBasicAuthEncodedString() string { - return base64.StdEncoding.EncodeToString([]byte(c.Username + ":" + c.Password)) -} - func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} - -func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { - if c.APIKeyPrefix[APIKeyIdentifier] != "" { - return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] - } - - return c.APIKey[APIKeyIdentifier] -} +} \ No newline at end of file diff --git a/examples/clients/responsebody/docs/ExamplepbResponseBodyOut.md b/examples/clients/responsebody/docs/ExamplepbResponseBodyOut.md index a26ce7530d0..5a7146581bf 100644 --- a/examples/clients/responsebody/docs/ExamplepbResponseBodyOut.md +++ b/examples/clients/responsebody/docs/ExamplepbResponseBodyOut.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Response** | [**ExamplepbResponseBodyOutResponse**](examplepbResponseBodyOutResponse.md) | | [optional] [default to null] +**Response** | [***ExamplepbResponseBodyOutResponse**](examplepbResponseBodyOutResponse.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/examples/clients/responsebody/docs/ResponseBodyServiceApi.md b/examples/clients/responsebody/docs/ResponseBodyServiceApi.md index 7c4506cc991..57d00db7633 100644 --- a/examples/clients/responsebody/docs/ResponseBodyServiceApi.md +++ b/examples/clients/responsebody/docs/ResponseBodyServiceApi.md @@ -8,16 +8,15 @@ Method | HTTP request | Description # **GetResponseBody** -> ExamplepbResponseBodyOutResponse GetResponseBody($data) +> ExamplepbResponseBodyOutResponse GetResponseBody(ctx, data) - - -### Parameters +### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **data** | **string**| | + **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **data** | **string**| | ### Return type diff --git a/examples/clients/responsebody/examplepb_response_body_out.go b/examples/clients/responsebody/examplepb_response_body_out.go index 72fae8bd52a..e633493dba8 100644 --- a/examples/clients/responsebody/examplepb_response_body_out.go +++ b/examples/clients/responsebody/examplepb_response_body_out.go @@ -1,16 +1,15 @@ -/* +/* * examples/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbResponseBodyOut struct { - Response ExamplepbResponseBodyOutResponse `json:"response,omitempty"` + Response *ExamplepbResponseBodyOutResponse `json:"response,omitempty"` } diff --git a/examples/clients/responsebody/examplepb_response_body_out_response.go b/examples/clients/responsebody/examplepb_response_body_out_response.go index ca14fa3e6a1..0167394ed01 100644 --- a/examples/clients/responsebody/examplepb_response_body_out_response.go +++ b/examples/clients/responsebody/examplepb_response_body_out_response.go @@ -1,11 +1,10 @@ -/* +/* * examples/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody diff --git a/examples/clients/responsebody/response_body_service_api.go b/examples/clients/responsebody/response_body_service_api.go index 15fa4e5bb63..942595374f6 100644 --- a/examples/clients/responsebody/response_body_service_api.go +++ b/examples/clients/responsebody/response_body_service_api.go @@ -1,99 +1,93 @@ -/* +/* * examples/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * - * Generated by: https://github.com/swagger-api/swagger-codegen.git + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "encoding/json" "fmt" ) -type ResponseBodyServiceApi struct { - Configuration *Configuration -} - -func NewResponseBodyServiceApi() *ResponseBodyServiceApi { - configuration := NewConfiguration() - return &ResponseBodyServiceApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -func NewResponseBodyServiceApiWithBasePath(basePath string) *ResponseBodyServiceApi { - configuration := NewConfiguration() - configuration.BasePath = basePath +type ResponseBodyServiceApiService service - return &ResponseBodyServiceApi{ - Configuration: configuration, - } -} -/** - * - * - * @param data - * @return *ExamplepbResponseBodyOutResponse - */ -func (a ResponseBodyServiceApi) GetResponseBody(data string) (*ExamplepbResponseBodyOutResponse, *APIResponse, error) { +/* ResponseBodyServiceApiService + * @param ctx context.Context for authentication, logging, tracing, etc. + @param data + @return ExamplepbResponseBodyOutResponse*/ +func (a *ResponseBodyServiceApiService) GetResponseBody(ctx context.Context, data string) (ExamplepbResponseBodyOutResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbResponseBodyOutResponse + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/responsebody/{data}" + localVarPath := a.client.cfg.BasePath + "/responsebody/{data}" localVarPath = strings.Replace(localVarPath, "{"+"data"+"}", fmt.Sprintf("%v", data), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ExamplepbResponseBodyOutResponse) - 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: "GetResponseBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err } - if err != nil { - return successPayload, localVarAPIResponse, err + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/clients/unannotatedecho/.swagger-codegen/VERSION b/examples/clients/unannotatedecho/.swagger-codegen/VERSION new file mode 100644 index 00000000000..717311e32e3 --- /dev/null +++ b/examples/clients/unannotatedecho/.swagger-codegen/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/examples/clients/unannotatedecho/api/swagger.yaml b/examples/clients/unannotatedecho/api/swagger.yaml new file mode 100644 index 00000000000..54cc1c3270f --- /dev/null +++ b/examples/clients/unannotatedecho/api/swagger.yaml @@ -0,0 +1,131 @@ +--- +swagger: "2.0" +info: + description: "Unannotated Echo Service\nSimilar to echo_service.proto but without\ + \ annotations. See\nunannotated_echo_service.yaml for the equivalent of the annotations\ + \ in\ngRPC API configuration format.\n\nEcho Service API consists of a single\ + \ service which returns\na message." + version: "version not set" + title: "examples/proto/examplepb/unannotated_echo_service.proto" +schemes: +- "http" +- "https" +consumes: +- "application/json" +produces: +- "application/json" +paths: + /v1/example/echo/{id}: + post: + tags: + - "UnannotatedEchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo" + parameters: + - name: "id" + in: "path" + description: "Id represents the message identifier." + required: true + type: "string" + x-exportParamName: "Id" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbUnannotatedSimpleMessage" + /v1/example/echo/{id}/{num}: + get: + tags: + - "UnannotatedEchoService" + summary: "Echo method receives a simple message and returns it." + description: "The message posted as the id parameter will also be\nreturned." + operationId: "Echo2" + parameters: + - name: "id" + in: "path" + description: "Id represents the message identifier." + required: true + type: "string" + x-exportParamName: "Id" + - name: "num" + in: "path" + required: true + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "duration" + in: "query" + required: false + type: "string" + x-exportParamName: "Duration" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbUnannotatedSimpleMessage" + /v1/example/echo_body: + post: + tags: + - "UnannotatedEchoService" + summary: "EchoBody method receives a simple message and returns it." + operationId: "EchoBody" + parameters: + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/examplepbUnannotatedSimpleMessage" + x-exportParamName: "Body" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbUnannotatedSimpleMessage" + /v1/example/echo_delete: + delete: + tags: + - "UnannotatedEchoService" + summary: "EchoDelete method receives a simple message and returns it." + operationId: "EchoDelete" + parameters: + - name: "id" + in: "query" + description: "Id represents the message identifier." + required: false + type: "string" + x-exportParamName: "Id" + - name: "num" + in: "query" + required: false + type: "string" + format: "int64" + x-exportParamName: "Num" + - name: "duration" + in: "query" + required: false + type: "string" + x-exportParamName: "Duration" + responses: + 200: + description: "" + schema: + $ref: "#/definitions/examplepbUnannotatedSimpleMessage" +definitions: + examplepbUnannotatedSimpleMessage: + type: "object" + properties: + id: + type: "string" + description: "Id represents the message identifier." + num: + type: "string" + format: "int64" + duration: + type: "string" + description: "UnannotatedSimpleMessage represents a simple message sent to the\ + \ unannotated Echo service." + example: + duration: "duration" + num: "num" + id: "id" diff --git a/examples/clients/unannotatedecho/api_client.go b/examples/clients/unannotatedecho/api_client.go index aa4c1f14e42..b7f5328c000 100644 --- a/examples/clients/unannotatedecho/api_client.go +++ b/examples/clients/unannotatedecho/api_client.go @@ -1,32 +1,79 @@ -/* +/* * examples/proto/examplepb/unannotated_echo_service.proto * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( "bytes" + "encoding/json" + "encoding/xml" "fmt" + "errors" + "io" + "mime/multipart" + "golang.org/x/oauth2" + "golang.org/x/net/context" + "net/http" + "net/url" + "time" + "os" "path/filepath" "reflect" + "regexp" "strings" - "net/url" - "io/ioutil" - "github.com/go-resty/resty" + "unicode/utf8" + "strconv" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) +// APIClient manages communication with the examples/proto/examplepb/unannotated_echo_service.proto API vversion not set +// In most cases there should be only one, shared, APIClient. type APIClient struct { - config *Configuration + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + UnannotatedEchoServiceApi *UnannotatedEchoServiceApiService } -func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { +type service struct { + client *APIClient +} +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.UnannotatedEchoServiceApi = (*UnannotatedEchoServiceApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } @@ -36,17 +83,20 @@ func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *APIClient) SelectHeaderAccept(accepts []string) string { - +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } + if contains(accepts, "application/json") { return "application/json" } + return strings.Join(accepts, ",") } +// contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { @@ -56,40 +106,24 @@ func contains(haystack []string, needle string) bool { return false } -func (c *APIClient) CallAPI(path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams url.Values, - formParams map[string]string, - fileName string, - fileBytes []byte) (*resty.Response, error) { - - rClient := c.prepareClient() - request := c.prepareRequest(rClient, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - switch strings.ToUpper(method) { - case "GET": - response, err := request.Get(path) - return response, err - case "POST": - response, err := request.Post(path) - return response, err - case "PUT": - response, err := request.Put(path) - return response, err - case "PATCH": - response, err := request.Patch(path) - return response, err - case "DELETE": - response, err := request.Delete(path) - return response, err - } - - return nil, fmt.Errorf("invalid method %v", method) -} - -func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) string { - delimiter := "" +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + switch collectionFormat { case "pipes": delimiter = "|" @@ -108,57 +142,287 @@ func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) return fmt.Sprintf("%v", obj) } -func (c *APIClient) prepareClient() *resty.Client { - - rClient := resty.New() - - rClient.SetDebug(c.config.Debug) - if c.config.Transport != nil { - rClient.SetTransport(c.config.Transport) - } +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} - if c.config.Timeout != nil { - rClient.SetTimeout(*c.config.Timeout) - } - rClient.SetLogger(ioutil.Discard) - return rClient +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath (path string) { + c.cfg.BasePath = path } -func (c *APIClient) prepareRequest( - rClient *resty.Client, +// prepareRequest build the request +func (c *APIClient) prepareRequest ( + ctx context.Context, + path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, - formParams map[string]string, + formParams url.Values, fileName string, - fileBytes []byte) *resty.Request { + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile("file", filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + } + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } - request := rClient.R() - request.SetBody(postBody) + // Encode the parameters. + url.RawQuery = query.Encode() - if c.config.UserAgent != "" { - request.SetHeader("User-Agent", c.config.UserAgent) + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err } - // add header parameter, if any + // add header parameters, if any if len(headerParams) > 0 { - request.SetHeaders(headerParams) + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers } - // add query parameter, if any - if len(queryParams) > 0 { - request.SetMultiValueQueryParams(queryParams) + // Override request host, if applicable + if c.cfg.Host != "" { + localVarRequest.Host = c.cfg.Host } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } - // add form parameter, if any - if len(formParams) > 0 { - request.SetFormData(formParams) + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer " + auth) + } } - if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) - request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) } - return request + + return localVarRequest, nil } + + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) (error) { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) (time.Time) { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } + expires = now.Add(lifetime) + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) (int) { + return utf8.RuneCountInString(s) +} + diff --git a/examples/clients/unannotatedecho/api_response.go b/examples/clients/unannotatedecho/api_response.go index 8d7af71022e..bcbc70d48d3 100644 --- a/examples/clients/unannotatedecho/api_response.go +++ b/examples/clients/unannotatedecho/api_response.go @@ -1,11 +1,10 @@ -/* +/* * examples/proto/examplepb/unannotated_echo_service.proto * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho diff --git a/examples/clients/unannotatedecho/configuration.go b/examples/clients/unannotatedecho/configuration.go index d8ed5f04501..3df4f0dab38 100644 --- a/examples/clients/unannotatedecho/configuration.go +++ b/examples/clients/unannotatedecho/configuration.go @@ -1,67 +1,72 @@ -/* +/* * examples/proto/examplepb/unannotated_echo_service.proto * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( - "encoding/base64" "net/http" - "time" ) +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKey takes an APIKey as authentication for the request + ContextAPIKey = contextKey("apikey") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} type Configuration struct { - Username string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` - APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"` - APIKey map[string]string `json:"APIKey,omitempty"` - Debug bool `json:"debug,omitempty"` - DebugFile string `json:"debugFile,omitempty"` - OAuthToken string `json:"oAuthToken,omitempty"` - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - AccessToken string `json:"accessToken,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - APIClient *APIClient - Transport *http.Transport - Timeout *time.Duration `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://localhost", DefaultHeader: make(map[string]string), - APIKey: make(map[string]string), - APIKeyPrefix: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", - APIClient: &APIClient{}, } - - cfg.APIClient.config = cfg return cfg } -func (c *Configuration) GetBasicAuthEncodedString() string { - return base64.StdEncoding.EncodeToString([]byte(c.Username + ":" + c.Password)) -} - func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} - -func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { - if c.APIKeyPrefix[APIKeyIdentifier] != "" { - return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] - } - - return c.APIKey[APIKeyIdentifier] -} +} \ No newline at end of file diff --git a/examples/clients/unannotatedecho/examplepb_unannotated_simple_message.go b/examples/clients/unannotatedecho/examplepb_unannotated_simple_message.go index 7791baa682b..bbe39bbcb81 100644 --- a/examples/clients/unannotatedecho/examplepb_unannotated_simple_message.go +++ b/examples/clients/unannotatedecho/examplepb_unannotated_simple_message.go @@ -1,11 +1,10 @@ -/* +/* * examples/proto/examplepb/unannotated_echo_service.proto * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho diff --git a/examples/clients/unannotatedecho/unannotated_echo_service_api.go b/examples/clients/unannotatedecho/unannotated_echo_service_api.go index cb3efdde4d4..22adc224a64 100644 --- a/examples/clients/unannotatedecho/unannotated_echo_service_api.go +++ b/examples/clients/unannotatedecho/unannotated_echo_service_api.go @@ -1,290 +1,318 @@ -/* +/* * examples/proto/examplepb/unannotated_echo_service.proto * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. 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 + * API version: version not set + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( + "io/ioutil" "net/url" + "net/http" "strings" + "golang.org/x/net/context" "encoding/json" "fmt" ) -type UnannotatedEchoServiceApi struct { - Configuration *Configuration -} - -func NewUnannotatedEchoServiceApi() *UnannotatedEchoServiceApi { - configuration := NewConfiguration() - return &UnannotatedEchoServiceApi{ - Configuration: configuration, - } -} +// Linger please +var ( + _ context.Context +) -func NewUnannotatedEchoServiceApiWithBasePath(basePath string) *UnannotatedEchoServiceApi { - configuration := NewConfiguration() - configuration.BasePath = basePath +type UnannotatedEchoServiceApiService service - return &UnannotatedEchoServiceApi{ - Configuration: configuration, - } -} -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id Id represents the message identifier. - * @return *ExamplepbUnannotatedSimpleMessage - */ -func (a UnannotatedEchoServiceApi) Echo(id string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +/* UnannotatedEchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id Id represents the message identifier. + @return ExamplepbUnannotatedSimpleMessage*/ +func (a *UnannotatedEchoServiceApiService) Echo(ctx context.Context, id string) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbUnannotatedSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ExamplepbUnannotatedSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. - * - * @param id Id represents the message identifier. - * @param num - * @param duration - * @return *ExamplepbUnannotatedSimpleMessage - */ -func (a UnannotatedEchoServiceApi) Echo2(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +/* UnannotatedEchoServiceApiService Echo method receives a simple message and returns it. + The message posted as the id parameter will also be returned. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param id Id represents the message identifier. + @param num + @param optional (nil or map[string]interface{}) with one or more of: + @param "duration" (string) + @return ExamplepbUnannotatedSimpleMessage*/ +func (a *UnannotatedEchoServiceApiService) Echo2(ctx context.Context, id string, num string, localVarOptionals map[string]interface{}) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbUnannotatedSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}/{num}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -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] + localVarFormParams := url.Values{} + + if err := typeCheckParameter(localVarOptionals["duration"], "string", "duration"); err != nil { + return successPayload, nil, err } - localVarQueryParams.Add("duration", a.Configuration.APIClient.ParameterToString(duration, "")) + if localVarTempParam, localVarOk := localVarOptionals["duration"].(string); localVarOk { + localVarQueryParams.Add("duration", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ExamplepbUnannotatedSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * EchoBody method receives a simple message and returns it. - * - * @param body - * @return *ExamplepbUnannotatedSimpleMessage - */ -func (a UnannotatedEchoServiceApi) EchoBody(body ExamplepbUnannotatedSimpleMessage) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +/* UnannotatedEchoServiceApiService EchoBody method receives a simple message and returns it. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param body + @return ExamplepbUnannotatedSimpleMessage*/ +func (a *UnannotatedEchoServiceApiService) EchoBody(ctx context.Context, body ExamplepbUnannotatedSimpleMessage) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbUnannotatedSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo_body" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo_body" 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] - } + localVarFormParams := url.Values{} + // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body - var successPayload = new(ExamplepbUnannotatedSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "EchoBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } -/** - * EchoDelete method receives a simple message and returns it. - * - * @param id Id represents the message identifier. - * @param num - * @param duration - * @return *ExamplepbUnannotatedSimpleMessage - */ -func (a UnannotatedEchoServiceApi) EchoDelete(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +/* UnannotatedEchoServiceApiService EchoDelete method receives a simple message and returns it. + * @param ctx context.Context for authentication, logging, tracing, etc. + @param optional (nil or map[string]interface{}) with one or more of: + @param "id" (string) Id represents the message identifier. + @param "num" (string) + @param "duration" (string) + @return ExamplepbUnannotatedSimpleMessage*/ +func (a *UnannotatedEchoServiceApiService) EchoDelete(ctx context.Context, localVarOptionals map[string]interface{}) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ExamplepbUnannotatedSimpleMessage + ) - var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo_delete" + localVarPath := a.client.cfg.BasePath + "/v1/example/echo_delete" 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("duration", a.Configuration.APIClient.ParameterToString(duration, "")) + localVarFormParams := url.Values{} + if err := typeCheckParameter(localVarOptionals["id"], "string", "id"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["num"], "string", "num"); err != nil { + return successPayload, nil, err + } + if err := typeCheckParameter(localVarOptionals["duration"], "string", "duration"); err != nil { + return successPayload, nil, err + } + + if localVarTempParam, localVarOk := localVarOptionals["id"].(string); localVarOk { + localVarQueryParams.Add("id", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["num"].(string); localVarOk { + localVarQueryParams.Add("num", parameterToString(localVarTempParam, "")) + } + if localVarTempParam, localVarOk := localVarOptionals["duration"].(string); localVarOk { + localVarQueryParams.Add("duration", parameterToString(localVarTempParam, "")) + } // to determine the Content-Type header localVarHttpContentTypes := []string{ "application/json", } // set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := 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) + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - var successPayload = new(ExamplepbUnannotatedSimpleMessage) - localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return successPayload, nil, err + } - var localVarURL, _ = url.Parse(localVarPath) - localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "EchoDelete", Method: localVarHttpMethod, RequestURL: localVarURL.String()} - if localVarHttpResponse != nil { - localVarAPIResponse.Response = localVarHttpResponse.RawResponse - localVarAPIResponse.Payload = localVarHttpResponse.Body() + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return successPayload, localVarHttpResponse, err + } + defer localVarHttpResponse.Body.Close() + if localVarHttpResponse.StatusCode >= 300 { + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - if err != nil { - return successPayload, localVarAPIResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err } - err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload) - return successPayload, localVarAPIResponse, err + + + return successPayload, localVarHttpResponse, err } diff --git a/examples/proto/examplepb/a_bit_of_everything.pb.go b/examples/proto/examplepb/a_bit_of_everything.pb.go index e53bcbd4fda..b703e687c7d 100644 --- a/examples/proto/examplepb/a_bit_of_everything.pb.go +++ b/examples/proto/examplepb/a_bit_of_everything.pb.go @@ -54,7 +54,7 @@ func (x NumericEnum) String() string { return proto.EnumName(NumericEnum_name, int32(x)) } func (NumericEnum) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{0} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{0} } // DeepEnum is one or zero. @@ -80,7 +80,7 @@ func (x ABitOfEverything_Nested_DeepEnum) String() string { return proto.EnumName(ABitOfEverything_Nested_DeepEnum_name, int32(x)) } func (ABitOfEverything_Nested_DeepEnum) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{0, 0, 0} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{0, 0, 0} } // Intentionaly complicated message type to cover many features of Protobuf. @@ -128,7 +128,7 @@ func (m *ABitOfEverything) Reset() { *m = ABitOfEverything{} } func (m *ABitOfEverything) String() string { return proto.CompactTextString(m) } func (*ABitOfEverything) ProtoMessage() {} func (*ABitOfEverything) Descriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{0} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{0} } func (m *ABitOfEverything) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ABitOfEverything.Unmarshal(m, b) @@ -466,7 +466,7 @@ func (m *ABitOfEverything_Nested) Reset() { *m = ABitOfEverything_Nested func (m *ABitOfEverything_Nested) String() string { return proto.CompactTextString(m) } func (*ABitOfEverything_Nested) ProtoMessage() {} func (*ABitOfEverything_Nested) Descriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{0, 0} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{0, 0} } func (m *ABitOfEverything_Nested) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ABitOfEverything_Nested.Unmarshal(m, b) @@ -535,7 +535,7 @@ func (m *ABitOfEverythingRepeated) Reset() { *m = ABitOfEverythingRepeat func (m *ABitOfEverythingRepeated) String() string { return proto.CompactTextString(m) } func (*ABitOfEverythingRepeated) ProtoMessage() {} func (*ABitOfEverythingRepeated) Descriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{1} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{1} } func (m *ABitOfEverythingRepeated) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ABitOfEverythingRepeated.Unmarshal(m, b) @@ -678,7 +678,7 @@ func (m *Body) Reset() { *m = Body{} } func (m *Body) String() string { return proto.CompactTextString(m) } func (*Body) ProtoMessage() {} func (*Body) Descriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{2} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{2} } func (m *Body) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Body.Unmarshal(m, b) @@ -717,7 +717,7 @@ func (m *MessageWithBody) Reset() { *m = MessageWithBody{} } func (m *MessageWithBody) String() string { return proto.CompactTextString(m) } func (*MessageWithBody) ProtoMessage() {} func (*MessageWithBody) Descriptor() ([]byte, []int) { - return fileDescriptor_a_bit_of_everything_34defd096f52c726, []int{3} + return fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38, []int{3} } func (m *MessageWithBody) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MessageWithBody.Unmarshal(m, b) @@ -1414,10 +1414,10 @@ var _AnotherServiceWithNoBindings_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/a_bit_of_everything.proto", fileDescriptor_a_bit_of_everything_34defd096f52c726) + proto.RegisterFile("examples/proto/examplepb/a_bit_of_everything.proto", fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38) } -var fileDescriptor_a_bit_of_everything_34defd096f52c726 = []byte{ +var fileDescriptor_a_bit_of_everything_7c7816b5eb73ac38 = []byte{ // 2708 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0x5f, 0x73, 0x1b, 0x57, 0x15, 0xf7, 0x6a, 0x65, 0xc5, 0x3e, 0xb6, 0x6c, 0xf9, 0x3a, 0x71, 0x6c, 0xc5, 0xad, 0x6f, 0xd4, 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 87e77be592c..af771b2c31f 100644 --- a/examples/proto/examplepb/a_bit_of_everything.pb.gw.go +++ b/examples/proto/examplepb/a_bit_of_everything.pb.gw.go @@ -202,17 +202,6 @@ 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_string"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "oneof_string") - } - - protoReq.alloc_OneofString().OneofString, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "oneof_string", err) - } - val, ok = pathParams["nonConventionalNameValue"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nonConventionalNameValue") @@ -692,27 +681,6 @@ func request_ABitOfEverythingService_DeepPathEcho_0(ctx context.Context, marshal } -var ( - filter_ABitOfEverythingService_DeepPathEcho_1 = &utilities.DoubleArray{Encoding: map[string]int{"oneof_string": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -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.alloc_OneofString().OneofString); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_DeepPathEcho_1); 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 @@ -1159,35 +1127,6 @@ 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(ctx) - 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("GET", pattern_ABitOfEverythingService_Timeout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1308,11 +1247,7 @@ func RegisterABitOfEverythingServiceHandlerClient(ctx context.Context, mux *runt } var ( -<<<<<<< HEAD:examples/proto/examplepb/a_bit_of_everything.pb.gw.go 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, 1, 0, 4, 1, 5, 21, 1, 0, 4, 1, 5, 22}, []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", "enum_value", "path_enum_value", "nested_path_enum_value"}, "")) -======= - 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_string", "nonConventionalNameValue"}, "")) ->>>>>>> Add an integration test for oneof fields in path parameters:examples/examplepb/a_bit_of_everything.pb.gw.go pattern_ABitOfEverythingService_CreateBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "a_bit_of_everything"}, "")) @@ -1334,8 +1269,6 @@ var ( 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_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v2", "example", "oneof", "echo"}, "")) - pattern_ABitOfEverythingService_Timeout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "timeout"}, "")) pattern_ABitOfEverythingService_ErrorWithDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "errorwithdetails"}, "")) @@ -1368,8 +1301,6 @@ var ( forward_ABitOfEverythingService_DeepPathEcho_0 = runtime.ForwardResponseMessage - forward_ABitOfEverythingService_DeepPathEcho_1 = runtime.ForwardResponseMessage - forward_ABitOfEverythingService_Timeout_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_ErrorWithDetails_0 = runtime.ForwardResponseMessage @@ -1456,21 +1387,3 @@ var ( var ( forward_CamelCaseServiceName_Empty_0 = runtime.ForwardResponseMessage ) - -func (m *ABitOfEverything) alloc_OneofEmpty() *ABitOfEverything_OneofEmpty { - if x, ok := m.OneofValue.(*ABitOfEverything_OneofEmpty); ok { - return x - } - x := new(ABitOfEverything_OneofEmpty) - m.OneofValue = x - return x -} - -func (m *ABitOfEverything) alloc_OneofString() *ABitOfEverything_OneofString { - if x, ok := m.OneofValue.(*ABitOfEverything_OneofString); ok { - return x - } - x := new(ABitOfEverything_OneofString) - m.OneofValue = x - return x -} diff --git a/examples/proto/examplepb/echo_service.pb.go b/examples/proto/examplepb/echo_service.pb.go index da8af13fbf9..482166c9a6f 100644 --- a/examples/proto/examplepb/echo_service.pb.go +++ b/examples/proto/examplepb/echo_service.pb.go @@ -46,7 +46,7 @@ func (m *Embedded) Reset() { *m = Embedded{} } func (m *Embedded) String() string { return proto.CompactTextString(m) } func (*Embedded) ProtoMessage() {} func (*Embedded) Descriptor() ([]byte, []int) { - return fileDescriptor_echo_service_c13a64d5f1f0c068, []int{0} + return fileDescriptor_echo_service_db3cc2defd36b477, []int{0} } func (m *Embedded) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Embedded.Unmarshal(m, b) @@ -191,7 +191,7 @@ func (m *SimpleMessage) Reset() { *m = SimpleMessage{} } func (m *SimpleMessage) String() string { return proto.CompactTextString(m) } func (*SimpleMessage) ProtoMessage() {} func (*SimpleMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_echo_service_c13a64d5f1f0c068, []int{1} + return fileDescriptor_echo_service_db3cc2defd36b477, []int{1} } func (m *SimpleMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SimpleMessage.Unmarshal(m, b) @@ -572,10 +572,10 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/echo_service.proto", fileDescriptor_echo_service_c13a64d5f1f0c068) + proto.RegisterFile("examples/proto/examplepb/echo_service.proto", fileDescriptor_echo_service_db3cc2defd36b477) } -var fileDescriptor_echo_service_c13a64d5f1f0c068 = []byte{ +var fileDescriptor_echo_service_db3cc2defd36b477 = []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, diff --git a/examples/proto/examplepb/flow_combination.pb.go b/examples/proto/examplepb/flow_combination.pb.go index 25e2b775e50..ebf5fc78843 100644 --- a/examples/proto/examplepb/flow_combination.pb.go +++ b/examples/proto/examplepb/flow_combination.pb.go @@ -34,7 +34,7 @@ func (m *EmptyProto) Reset() { *m = EmptyProto{} } func (m *EmptyProto) String() string { return proto.CompactTextString(m) } func (*EmptyProto) ProtoMessage() {} func (*EmptyProto) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_combination_40371c0acedc1fc5, []int{0} + return fileDescriptor_flow_combination_4026ea65f3b791e2, []int{0} } func (m *EmptyProto) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_EmptyProto.Unmarshal(m, b) @@ -67,7 +67,7 @@ func (m *NonEmptyProto) Reset() { *m = NonEmptyProto{} } func (m *NonEmptyProto) String() string { return proto.CompactTextString(m) } func (*NonEmptyProto) ProtoMessage() {} func (*NonEmptyProto) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_combination_40371c0acedc1fc5, []int{1} + return fileDescriptor_flow_combination_4026ea65f3b791e2, []int{1} } func (m *NonEmptyProto) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_NonEmptyProto.Unmarshal(m, b) @@ -119,7 +119,7 @@ func (m *UnaryProto) Reset() { *m = UnaryProto{} } func (m *UnaryProto) String() string { return proto.CompactTextString(m) } func (*UnaryProto) ProtoMessage() {} func (*UnaryProto) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_combination_40371c0acedc1fc5, []int{2} + return fileDescriptor_flow_combination_4026ea65f3b791e2, []int{2} } func (m *UnaryProto) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UnaryProto.Unmarshal(m, b) @@ -159,7 +159,7 @@ func (m *NestedProto) Reset() { *m = NestedProto{} } func (m *NestedProto) String() string { return proto.CompactTextString(m) } func (*NestedProto) ProtoMessage() {} func (*NestedProto) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_combination_40371c0acedc1fc5, []int{3} + return fileDescriptor_flow_combination_4026ea65f3b791e2, []int{3} } func (m *NestedProto) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_NestedProto.Unmarshal(m, b) @@ -211,7 +211,7 @@ func (m *SingleNestedProto) Reset() { *m = SingleNestedProto{} } func (m *SingleNestedProto) String() string { return proto.CompactTextString(m) } func (*SingleNestedProto) ProtoMessage() {} func (*SingleNestedProto) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_combination_40371c0acedc1fc5, []int{4} + return fileDescriptor_flow_combination_4026ea65f3b791e2, []int{4} } func (m *SingleNestedProto) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SingleNestedProto.Unmarshal(m, b) @@ -791,10 +791,10 @@ var _FlowCombination_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/flow_combination.proto", fileDescriptor_flow_combination_40371c0acedc1fc5) + proto.RegisterFile("examples/proto/examplepb/flow_combination.proto", fileDescriptor_flow_combination_4026ea65f3b791e2) } -var fileDescriptor_flow_combination_40371c0acedc1fc5 = []byte{ +var fileDescriptor_flow_combination_4026ea65f3b791e2 = []byte{ // 655 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0xbf, 0x8f, 0x12, 0x41, 0x14, 0xc7, 0xf3, 0xb8, 0xc4, 0xe4, 0x86, 0xfb, 0xc1, 0x2d, 0x06, 0x81, 0xc3, 0xe3, 0x6e, 0xbc, diff --git a/examples/proto/examplepb/response_body_service.pb.go b/examples/proto/examplepb/response_body_service.pb.go index fcad76e5898..63da9101516 100644 --- a/examples/proto/examplepb/response_body_service.pb.go +++ b/examples/proto/examplepb/response_body_service.pb.go @@ -35,7 +35,7 @@ func (m *ResponseBodyIn) Reset() { *m = ResponseBodyIn{} } func (m *ResponseBodyIn) String() string { return proto.CompactTextString(m) } func (*ResponseBodyIn) ProtoMessage() {} func (*ResponseBodyIn) Descriptor() ([]byte, []int) { - return fileDescriptor_response_body_service_5010ebf28bf7b965, []int{0} + return fileDescriptor_response_body_service_a87347c4d2918612, []int{0} } func (m *ResponseBodyIn) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ResponseBodyIn.Unmarshal(m, b) @@ -73,7 +73,7 @@ func (m *ResponseBodyOut) Reset() { *m = ResponseBodyOut{} } func (m *ResponseBodyOut) String() string { return proto.CompactTextString(m) } func (*ResponseBodyOut) ProtoMessage() {} func (*ResponseBodyOut) Descriptor() ([]byte, []int) { - return fileDescriptor_response_body_service_5010ebf28bf7b965, []int{1} + return fileDescriptor_response_body_service_a87347c4d2918612, []int{1} } func (m *ResponseBodyOut) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ResponseBodyOut.Unmarshal(m, b) @@ -111,7 +111,7 @@ func (m *ResponseBodyOut_Response) Reset() { *m = ResponseBodyOut_Respon func (m *ResponseBodyOut_Response) String() string { return proto.CompactTextString(m) } func (*ResponseBodyOut_Response) ProtoMessage() {} func (*ResponseBodyOut_Response) Descriptor() ([]byte, []int) { - return fileDescriptor_response_body_service_5010ebf28bf7b965, []int{1, 0} + return fileDescriptor_response_body_service_a87347c4d2918612, []int{1, 0} } func (m *ResponseBodyOut_Response) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ResponseBodyOut_Response.Unmarshal(m, b) @@ -217,10 +217,10 @@ var _ResponseBodyService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/response_body_service.proto", fileDescriptor_response_body_service_5010ebf28bf7b965) + proto.RegisterFile("examples/proto/examplepb/response_body_service.proto", fileDescriptor_response_body_service_a87347c4d2918612) } -var fileDescriptor_response_body_service_5010ebf28bf7b965 = []byte{ +var fileDescriptor_response_body_service_a87347c4d2918612 = []byte{ // 257 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x49, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x87, 0x72, 0x0b, 0x92, 0xf4, diff --git a/examples/proto/examplepb/stream.pb.go b/examples/proto/examplepb/stream.pb.go index cc0c274c8ea..3deecf3ca3a 100644 --- a/examples/proto/examplepb/stream.pb.go +++ b/examples/proto/examplepb/stream.pb.go @@ -258,10 +258,10 @@ var _StreamService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/stream.proto", fileDescriptor_stream_0929397c5d8d3331) + proto.RegisterFile("examples/proto/examplepb/stream.proto", fileDescriptor_stream_c8bbbb01c5cf053e) } -var fileDescriptor_stream_0929397c5d8d3331 = []byte{ +var fileDescriptor_stream_c8bbbb01c5cf053e = []byte{ // 319 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0xb1, 0x4e, 0xc3, 0x30, 0x10, 0x86, 0x15, 0x40, 0x08, 0x8c, 0x58, 0x3c, 0x30, 0x04, 0xa4, 0x42, 0x05, 0xa2, 0x30, 0xd8, diff --git a/examples/proto/examplepb/unannotated_echo_service.pb.go b/examples/proto/examplepb/unannotated_echo_service.pb.go index 28f0d7311d0..819190d05f6 100644 --- a/examples/proto/examplepb/unannotated_echo_service.pb.go +++ b/examples/proto/examplepb/unannotated_echo_service.pb.go @@ -49,7 +49,7 @@ func (m *UnannotatedSimpleMessage) Reset() { *m = UnannotatedSimpleMessa func (m *UnannotatedSimpleMessage) String() string { return proto.CompactTextString(m) } func (*UnannotatedSimpleMessage) ProtoMessage() {} func (*UnannotatedSimpleMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_unannotated_echo_service_33987b03bf51a339, []int{0} + return fileDescriptor_unannotated_echo_service_2965fc76f23d12bd, []int{0} } func (m *UnannotatedSimpleMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UnannotatedSimpleMessage.Unmarshal(m, b) @@ -245,10 +245,10 @@ var _UnannotatedEchoService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/unannotated_echo_service.proto", fileDescriptor_unannotated_echo_service_33987b03bf51a339) + proto.RegisterFile("examples/proto/examplepb/unannotated_echo_service.proto", fileDescriptor_unannotated_echo_service_2965fc76f23d12bd) } -var fileDescriptor_unannotated_echo_service_33987b03bf51a339 = []byte{ +var fileDescriptor_unannotated_echo_service_2965fc76f23d12bd = []byte{ // 268 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4f, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x87, 0x72, 0x0b, 0x92, 0xf4, diff --git a/examples/proto/examplepb/wrappers.pb.go b/examples/proto/examplepb/wrappers.pb.go index fb44ca7aba9..a70687cbab5 100644 --- a/examples/proto/examplepb/wrappers.pb.go +++ b/examples/proto/examplepb/wrappers.pb.go @@ -44,7 +44,7 @@ func (m *Wrappers) Reset() { *m = Wrappers{} } func (m *Wrappers) String() string { return proto.CompactTextString(m) } func (*Wrappers) ProtoMessage() {} func (*Wrappers) Descriptor() ([]byte, []int) { - return fileDescriptor_wrappers_5850bd48b0187754, []int{0} + return fileDescriptor_wrappers_0cd12813574dca64, []int{0} } func (m *Wrappers) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Wrappers.Unmarshal(m, b) @@ -204,10 +204,10 @@ var _WrappersService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/wrappers.proto", fileDescriptor_wrappers_5850bd48b0187754) + proto.RegisterFile("examples/proto/examplepb/wrappers.proto", fileDescriptor_wrappers_0cd12813574dca64) } -var fileDescriptor_wrappers_5850bd48b0187754 = []byte{ +var fileDescriptor_wrappers_0cd12813574dca64 = []byte{ // 381 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xdf, 0x4a, 0xf3, 0x30, 0x18, 0xc6, 0xe9, 0xbe, 0x7d, 0x73, 0x4b, 0x05, 0xa1, 0x78, 0xa0, 0x75, 0x38, 0xd9, 0x89, 0x7f, diff --git a/examples/proto/pathenum/path_enum.pb.go b/examples/proto/pathenum/path_enum.pb.go index 6de95037484..978d839fe18 100644 --- a/examples/proto/pathenum/path_enum.pb.go +++ b/examples/proto/pathenum/path_enum.pb.go @@ -38,7 +38,7 @@ func (x PathEnum) String() string { return proto.EnumName(PathEnum_name, int32(x)) } func (PathEnum) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_path_enum_f14abf5268452f40, []int{0} + return fileDescriptor_path_enum_a83081a8771b5cad, []int{0} } type MessagePathEnum_NestedPathEnum int32 @@ -61,7 +61,7 @@ func (x MessagePathEnum_NestedPathEnum) String() string { return proto.EnumName(MessagePathEnum_NestedPathEnum_name, int32(x)) } func (MessagePathEnum_NestedPathEnum) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_path_enum_f14abf5268452f40, []int{0, 0} + return fileDescriptor_path_enum_a83081a8771b5cad, []int{0, 0} } type MessagePathEnum struct { @@ -74,7 +74,7 @@ func (m *MessagePathEnum) Reset() { *m = MessagePathEnum{} } func (m *MessagePathEnum) String() string { return proto.CompactTextString(m) } func (*MessagePathEnum) ProtoMessage() {} func (*MessagePathEnum) Descriptor() ([]byte, []int) { - return fileDescriptor_path_enum_f14abf5268452f40, []int{0} + return fileDescriptor_path_enum_a83081a8771b5cad, []int{0} } func (m *MessagePathEnum) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MessagePathEnum.Unmarshal(m, b) @@ -101,10 +101,10 @@ func init() { } func init() { - proto.RegisterFile("examples/proto/pathenum/path_enum.proto", fileDescriptor_path_enum_f14abf5268452f40) + proto.RegisterFile("examples/proto/pathenum/path_enum.proto", fileDescriptor_path_enum_a83081a8771b5cad) } -var fileDescriptor_path_enum_f14abf5268452f40 = []byte{ +var fileDescriptor_path_enum_a83081a8771b5cad = []byte{ // 175 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x48, 0x2c, 0xc9, 0x48, diff --git a/examples/proto/sub/message.pb.go b/examples/proto/sub/message.pb.go index 81612434029..a1e1a37134b 100644 --- a/examples/proto/sub/message.pb.go +++ b/examples/proto/sub/message.pb.go @@ -29,7 +29,7 @@ func (m *StringMessage) Reset() { *m = StringMessage{} } func (m *StringMessage) String() string { return proto.CompactTextString(m) } func (*StringMessage) ProtoMessage() {} func (*StringMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_message_c180d3d1a4bbfe02, []int{0} + return fileDescriptor_message_92435a9ec72b637d, []int{0} } func (m *StringMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StringMessage.Unmarshal(m, b) @@ -61,10 +61,10 @@ func init() { } func init() { - proto.RegisterFile("examples/proto/sub/message.proto", fileDescriptor_message_c180d3d1a4bbfe02) + proto.RegisterFile("examples/proto/sub/message.proto", fileDescriptor_message_92435a9ec72b637d) } -var fileDescriptor_message_c180d3d1a4bbfe02 = []byte{ +var fileDescriptor_message_92435a9ec72b637d = []byte{ // 114 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x2e, 0x4d, 0xd2, 0xcf, diff --git a/examples/proto/sub2/message.pb.go b/examples/proto/sub2/message.pb.go index 6819b67ae3c..4d2055b19bf 100644 --- a/examples/proto/sub2/message.pb.go +++ b/examples/proto/sub2/message.pb.go @@ -29,7 +29,7 @@ func (m *IdMessage) Reset() { *m = IdMessage{} } func (m *IdMessage) String() string { return proto.CompactTextString(m) } func (*IdMessage) ProtoMessage() {} func (*IdMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_message_1fa155de06adc960, []int{0} + return fileDescriptor_message_8d5058434f4f209b, []int{0} } func (m *IdMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_IdMessage.Unmarshal(m, b) @@ -61,10 +61,10 @@ func init() { } func init() { - proto.RegisterFile("examples/proto/sub2/message.proto", fileDescriptor_message_1fa155de06adc960) + proto.RegisterFile("examples/proto/sub2/message.proto", fileDescriptor_message_8d5058434f4f209b) } -var fileDescriptor_message_1fa155de06adc960 = []byte{ +var fileDescriptor_message_8d5058434f4f209b = []byte{ // 130 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x2e, 0x4d, 0x32, 0xd2, diff --git a/protoc-gen-swagger/options/annotations.pb.go b/protoc-gen-swagger/options/annotations.pb.go deleted file mode 100644 index a743078b45c..00000000000 --- a/protoc-gen-swagger/options/annotations.pb.go +++ /dev/null @@ -1,103 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: protoc-gen-swagger/options/annotations.proto - -package options // import "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -var E_Openapiv2Swagger = &proto.ExtensionDesc{ - ExtendedType: (*descriptor.FileOptions)(nil), - ExtensionType: (*Swagger)(nil), - Field: 1042, - Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger", - Tag: "bytes,1042,opt,name=openapiv2_swagger,json=openapiv2Swagger", - Filename: "protoc-gen-swagger/options/annotations.proto", -} - -var E_Openapiv2Operation = &proto.ExtensionDesc{ - ExtendedType: (*descriptor.MethodOptions)(nil), - ExtensionType: (*Operation)(nil), - Field: 1042, - Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_operation", - Tag: "bytes,1042,opt,name=openapiv2_operation,json=openapiv2Operation", - Filename: "protoc-gen-swagger/options/annotations.proto", -} - -var E_Openapiv2Schema = &proto.ExtensionDesc{ - ExtendedType: (*descriptor.MessageOptions)(nil), - ExtensionType: (*Schema)(nil), - Field: 1042, - Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_schema", - Tag: "bytes,1042,opt,name=openapiv2_schema,json=openapiv2Schema", - Filename: "protoc-gen-swagger/options/annotations.proto", -} - -var E_Openapiv2Tag = &proto.ExtensionDesc{ - ExtendedType: (*descriptor.ServiceOptions)(nil), - ExtensionType: (*Tag)(nil), - Field: 1042, - Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_tag", - Tag: "bytes,1042,opt,name=openapiv2_tag,json=openapiv2Tag", - Filename: "protoc-gen-swagger/options/annotations.proto", -} - -var E_Openapiv2Field = &proto.ExtensionDesc{ - ExtendedType: (*descriptor.FieldOptions)(nil), - ExtensionType: (*JSONSchema)(nil), - Field: 1042, - Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_field", - Tag: "bytes,1042,opt,name=openapiv2_field,json=openapiv2Field", - Filename: "protoc-gen-swagger/options/annotations.proto", -} - -func init() { - proto.RegisterExtension(E_Openapiv2Swagger) - proto.RegisterExtension(E_Openapiv2Operation) - proto.RegisterExtension(E_Openapiv2Schema) - proto.RegisterExtension(E_Openapiv2Tag) - proto.RegisterExtension(E_Openapiv2Field) -} - -func init() { - proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor_annotations_24d91a1b8877b604) -} - -var fileDescriptor_annotations_24d91a1b8877b604 = []byte{ - // 346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0x4f, 0xea, 0x40, - 0x14, 0xc5, 0xc3, 0xe6, 0xe5, 0xa5, 0xef, 0xa9, 0x58, 0x37, 0x86, 0xf8, 0x87, 0x9d, 0xc6, 0xc0, - 0x8c, 0x81, 0x5d, 0x77, 0x6a, 0xe2, 0xc2, 0x44, 0x49, 0x0a, 0x2b, 0x37, 0x64, 0x18, 0x2e, 0x97, - 0x49, 0x4a, 0xef, 0x64, 0x66, 0x80, 0x90, 0xb0, 0xf4, 0x13, 0xf8, 0x89, 0x8d, 0xd3, 0xd2, 0x9a, - 0x8a, 0xa6, 0xbb, 0xde, 0xdb, 0x39, 0xe7, 0x77, 0x7a, 0x3a, 0x41, 0x47, 0x1b, 0x72, 0x24, 0xbb, - 0x08, 0x69, 0xd7, 0xae, 0x05, 0x22, 0x18, 0x4e, 0xda, 0x29, 0x4a, 0x2d, 0x17, 0x69, 0x4a, 0x4e, - 0xf8, 0x67, 0xe6, 0x8f, 0x85, 0x57, 0x68, 0xb4, 0x64, 0x28, 0x1c, 0xac, 0xc5, 0x26, 0xdb, 0xc9, - 0x31, 0x42, 0x3a, 0xce, 0xa5, 0x2c, 0x97, 0xb6, 0x6e, 0x7e, 0xb1, 0x25, 0x0d, 0xa9, 0xd0, 0x6a, - 0xd5, 0xcb, 0x0c, 0x5a, 0x6d, 0x24, 0xc2, 0x04, 0xb8, 0x9f, 0x26, 0xcb, 0x19, 0x9f, 0x82, 0x95, - 0x46, 0x69, 0x47, 0x26, 0x3b, 0x11, 0x6d, 0x83, 0xe3, 0x42, 0xb4, 0x43, 0x85, 0x67, 0x2c, 0xd3, - 0xb1, 0x9d, 0x8e, 0x3d, 0xaa, 0x04, 0x06, 0x19, 0xe4, 0xf4, 0xfd, 0x6f, 0xbb, 0x71, 0xfd, 0xaf, - 0x77, 0xcb, 0x6a, 0x26, 0x66, 0xc3, 0x6c, 0x8e, 0x9b, 0x05, 0x29, 0xdf, 0x44, 0x6f, 0x8d, 0xe0, - 0xa4, 0xc4, 0x93, 0x06, 0xe3, 0x3b, 0x09, 0x2f, 0xbe, 0x05, 0x78, 0x06, 0x37, 0xa7, 0x69, 0x25, - 0x42, 0xaf, 0x76, 0x84, 0xc1, 0xce, 0x3a, 0x0e, 0x0b, 0x5e, 0xb1, 0x8b, 0xb6, 0x41, 0xf3, 0x4b, - 0x09, 0x72, 0x0e, 0x0b, 0x11, 0x5e, 0xee, 0x89, 0x60, 0xad, 0xc0, 0x6a, 0x0d, 0xbc, 0x7e, 0x0d, - 0xde, 0x38, 0x3e, 0x2a, 0x5b, 0xf0, 0x8b, 0xc8, 0x06, 0x07, 0x25, 0xdd, 0x09, 0xdc, 0x83, 0x1e, - 0x82, 0x59, 0x29, 0x59, 0x45, 0x77, 0x6a, 0xa3, 0x47, 0x02, 0xe3, 0xff, 0x05, 0x64, 0x24, 0x30, - 0xda, 0x06, 0x65, 0x8e, 0xf1, 0x4c, 0x41, 0x32, 0x0d, 0xcf, 0xf7, 0xfc, 0x75, 0x48, 0xaa, 0x9d, - 0xf7, 0x6b, 0x43, 0x9f, 0x86, 0x83, 0x97, 0xfc, 0x9b, 0x0f, 0x0b, 0x96, 0xb7, 0xbc, 0x7f, 0x78, - 0xbd, 0x43, 0xe5, 0xe6, 0xcb, 0x09, 0x93, 0xb4, 0xe0, 0x9f, 0x86, 0x5d, 0x90, 0x64, 0x37, 0xd6, - 0x41, 0x3e, 0xe6, 0xfe, 0xfc, 0xe7, 0xcb, 0x3e, 0xf9, 0xe3, 0xdf, 0xf5, 0x3f, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x4b, 0xc4, 0x41, 0xfb, 0x68, 0x03, 0x00, 0x00, -} diff --git a/protoc-gen-swagger/options/openapiv2.pb.go b/protoc-gen-swagger/options/openapiv2.pb.go deleted file mode 100644 index 931bc38f441..00000000000 --- a/protoc-gen-swagger/options/openapiv2.pb.go +++ /dev/null @@ -1,1469 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: protoc-gen-swagger/options/openapiv2.proto - -package options // import "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import any "github.com/golang/protobuf/ptypes/any" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Swagger_SwaggerScheme int32 - -const ( - Swagger_UNKNOWN Swagger_SwaggerScheme = 0 - Swagger_HTTP Swagger_SwaggerScheme = 1 - Swagger_HTTPS Swagger_SwaggerScheme = 2 - Swagger_WS Swagger_SwaggerScheme = 3 - Swagger_WSS Swagger_SwaggerScheme = 4 -) - -var Swagger_SwaggerScheme_name = map[int32]string{ - 0: "UNKNOWN", - 1: "HTTP", - 2: "HTTPS", - 3: "WS", - 4: "WSS", -} -var Swagger_SwaggerScheme_value = map[string]int32{ - "UNKNOWN": 0, - "HTTP": 1, - "HTTPS": 2, - "WS": 3, - "WSS": 4, -} - -func (x Swagger_SwaggerScheme) String() string { - return proto.EnumName(Swagger_SwaggerScheme_name, int32(x)) -} -func (Swagger_SwaggerScheme) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{0, 0} -} - -type JSONSchema_JSONSchemaSimpleTypes int32 - -const ( - JSONSchema_UNKNOWN JSONSchema_JSONSchemaSimpleTypes = 0 - JSONSchema_ARRAY JSONSchema_JSONSchemaSimpleTypes = 1 - JSONSchema_BOOLEAN JSONSchema_JSONSchemaSimpleTypes = 2 - JSONSchema_INTEGER JSONSchema_JSONSchemaSimpleTypes = 3 - JSONSchema_NULL JSONSchema_JSONSchemaSimpleTypes = 4 - JSONSchema_NUMBER JSONSchema_JSONSchemaSimpleTypes = 5 - JSONSchema_OBJECT JSONSchema_JSONSchemaSimpleTypes = 6 - JSONSchema_STRING JSONSchema_JSONSchemaSimpleTypes = 7 -) - -var JSONSchema_JSONSchemaSimpleTypes_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ARRAY", - 2: "BOOLEAN", - 3: "INTEGER", - 4: "NULL", - 5: "NUMBER", - 6: "OBJECT", - 7: "STRING", -} -var JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{ - "UNKNOWN": 0, - "ARRAY": 1, - "BOOLEAN": 2, - "INTEGER": 3, - "NULL": 4, - "NUMBER": 5, - "OBJECT": 6, - "STRING": 7, -} - -func (x JSONSchema_JSONSchemaSimpleTypes) String() string { - return proto.EnumName(JSONSchema_JSONSchemaSimpleTypes_name, int32(x)) -} -func (JSONSchema_JSONSchemaSimpleTypes) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{7, 0} -} - -// Required. The type of the security scheme. Valid values are "basic", -// "apiKey" or "oauth2". -type SecurityScheme_Type int32 - -const ( - SecurityScheme_TYPE_INVALID SecurityScheme_Type = 0 - SecurityScheme_TYPE_BASIC SecurityScheme_Type = 1 - SecurityScheme_TYPE_API_KEY SecurityScheme_Type = 2 - SecurityScheme_TYPE_OAUTH2 SecurityScheme_Type = 3 -) - -var SecurityScheme_Type_name = map[int32]string{ - 0: "TYPE_INVALID", - 1: "TYPE_BASIC", - 2: "TYPE_API_KEY", - 3: "TYPE_OAUTH2", -} -var SecurityScheme_Type_value = map[string]int32{ - "TYPE_INVALID": 0, - "TYPE_BASIC": 1, - "TYPE_API_KEY": 2, - "TYPE_OAUTH2": 3, -} - -func (x SecurityScheme_Type) String() string { - return proto.EnumName(SecurityScheme_Type_name, int32(x)) -} -func (SecurityScheme_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{10, 0} -} - -// Required. The location of the API key. Valid values are "query" or "header". -type SecurityScheme_In int32 - -const ( - SecurityScheme_IN_INVALID SecurityScheme_In = 0 - SecurityScheme_IN_QUERY SecurityScheme_In = 1 - SecurityScheme_IN_HEADER SecurityScheme_In = 2 -) - -var SecurityScheme_In_name = map[int32]string{ - 0: "IN_INVALID", - 1: "IN_QUERY", - 2: "IN_HEADER", -} -var SecurityScheme_In_value = map[string]int32{ - "IN_INVALID": 0, - "IN_QUERY": 1, - "IN_HEADER": 2, -} - -func (x SecurityScheme_In) String() string { - return proto.EnumName(SecurityScheme_In_name, int32(x)) -} -func (SecurityScheme_In) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{10, 1} -} - -// Required. The flow used by the OAuth2 security scheme. Valid values are -// "implicit", "password", "application" or "accessCode". -type SecurityScheme_Flow int32 - -const ( - SecurityScheme_FLOW_INVALID SecurityScheme_Flow = 0 - SecurityScheme_FLOW_IMPLICIT SecurityScheme_Flow = 1 - SecurityScheme_FLOW_PASSWORD SecurityScheme_Flow = 2 - SecurityScheme_FLOW_APPLICATION SecurityScheme_Flow = 3 - SecurityScheme_FLOW_ACCESS_CODE SecurityScheme_Flow = 4 -) - -var SecurityScheme_Flow_name = map[int32]string{ - 0: "FLOW_INVALID", - 1: "FLOW_IMPLICIT", - 2: "FLOW_PASSWORD", - 3: "FLOW_APPLICATION", - 4: "FLOW_ACCESS_CODE", -} -var SecurityScheme_Flow_value = map[string]int32{ - "FLOW_INVALID": 0, - "FLOW_IMPLICIT": 1, - "FLOW_PASSWORD": 2, - "FLOW_APPLICATION": 3, - "FLOW_ACCESS_CODE": 4, -} - -func (x SecurityScheme_Flow) String() string { - return proto.EnumName(SecurityScheme_Flow_name, int32(x)) -} -func (SecurityScheme_Flow) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{10, 2} -} - -// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject -// -// TODO(ivucica): document fields -type Swagger struct { - Swagger string `protobuf:"bytes,1,opt,name=swagger,proto3" json:"swagger,omitempty"` - Info *Info `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` - Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` - BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath,proto3" json:"base_path,omitempty"` - Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` - Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` - Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` - Responses map[string]*Response `protobuf:"bytes,10,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SecurityDefinitions *SecurityDefinitions `protobuf:"bytes,11,opt,name=security_definitions,json=securityDefinitions,proto3" json:"security_definitions,omitempty"` - Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Swagger) Reset() { *m = Swagger{} } -func (m *Swagger) String() string { return proto.CompactTextString(m) } -func (*Swagger) ProtoMessage() {} -func (*Swagger) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{0} -} -func (m *Swagger) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Swagger.Unmarshal(m, b) -} -func (m *Swagger) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Swagger.Marshal(b, m, deterministic) -} -func (dst *Swagger) XXX_Merge(src proto.Message) { - xxx_messageInfo_Swagger.Merge(dst, src) -} -func (m *Swagger) XXX_Size() int { - return xxx_messageInfo_Swagger.Size(m) -} -func (m *Swagger) XXX_DiscardUnknown() { - xxx_messageInfo_Swagger.DiscardUnknown(m) -} - -var xxx_messageInfo_Swagger proto.InternalMessageInfo - -func (m *Swagger) GetSwagger() string { - if m != nil { - return m.Swagger - } - return "" -} - -func (m *Swagger) GetInfo() *Info { - if m != nil { - return m.Info - } - return nil -} - -func (m *Swagger) GetHost() string { - if m != nil { - return m.Host - } - return "" -} - -func (m *Swagger) GetBasePath() string { - if m != nil { - return m.BasePath - } - return "" -} - -func (m *Swagger) GetSchemes() []Swagger_SwaggerScheme { - if m != nil { - return m.Schemes - } - return nil -} - -func (m *Swagger) GetConsumes() []string { - if m != nil { - return m.Consumes - } - return nil -} - -func (m *Swagger) GetProduces() []string { - if m != nil { - return m.Produces - } - return nil -} - -func (m *Swagger) GetResponses() map[string]*Response { - if m != nil { - return m.Responses - } - return nil -} - -func (m *Swagger) GetSecurityDefinitions() *SecurityDefinitions { - if m != nil { - return m.SecurityDefinitions - } - return nil -} - -func (m *Swagger) GetSecurity() []*SecurityRequirement { - if m != nil { - return m.Security - } - return nil -} - -func (m *Swagger) GetExternalDocs() *ExternalDocumentation { - if m != nil { - return m.ExternalDocs - } - return nil -} - -// `Operation` is a representation of OpenAPI v2 specification's Operation object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject -// -// TODO(ivucica): document fields -type Operation struct { - Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` - Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` - OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"` - Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` - Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` - Responses map[string]*Response `protobuf:"bytes,9,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Schemes []string `protobuf:"bytes,10,rep,name=schemes,proto3" json:"schemes,omitempty"` - Deprecated bool `protobuf:"varint,11,opt,name=deprecated,proto3" json:"deprecated,omitempty"` - Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Operation) Reset() { *m = Operation{} } -func (m *Operation) String() string { return proto.CompactTextString(m) } -func (*Operation) ProtoMessage() {} -func (*Operation) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{1} -} -func (m *Operation) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Operation.Unmarshal(m, b) -} -func (m *Operation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Operation.Marshal(b, m, deterministic) -} -func (dst *Operation) XXX_Merge(src proto.Message) { - xxx_messageInfo_Operation.Merge(dst, src) -} -func (m *Operation) XXX_Size() int { - return xxx_messageInfo_Operation.Size(m) -} -func (m *Operation) XXX_DiscardUnknown() { - xxx_messageInfo_Operation.DiscardUnknown(m) -} - -var xxx_messageInfo_Operation proto.InternalMessageInfo - -func (m *Operation) GetTags() []string { - if m != nil { - return m.Tags - } - return nil -} - -func (m *Operation) GetSummary() string { - if m != nil { - return m.Summary - } - return "" -} - -func (m *Operation) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Operation) GetExternalDocs() *ExternalDocumentation { - if m != nil { - return m.ExternalDocs - } - return nil -} - -func (m *Operation) GetOperationId() string { - if m != nil { - return m.OperationId - } - return "" -} - -func (m *Operation) GetConsumes() []string { - if m != nil { - return m.Consumes - } - return nil -} - -func (m *Operation) GetProduces() []string { - if m != nil { - return m.Produces - } - return nil -} - -func (m *Operation) GetResponses() map[string]*Response { - if m != nil { - return m.Responses - } - return nil -} - -func (m *Operation) GetSchemes() []string { - if m != nil { - return m.Schemes - } - return nil -} - -func (m *Operation) GetDeprecated() bool { - if m != nil { - return m.Deprecated - } - return false -} - -func (m *Operation) GetSecurity() []*SecurityRequirement { - if m != nil { - return m.Security - } - return nil -} - -// `Response` is a representation of OpenAPI v2 specification's Response object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject -// -type Response struct { - // `Description` is a short description of the response. - // GFM syntax can be used for rich text representation. - Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` - // `Schema` optionally defines the structure of the response. - // If `Schema` is not provided, it means there is no content to the response. - Schema *Schema `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto.CompactTextString(m) } -func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{2} -} -func (m *Response) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Response.Unmarshal(m, b) -} -func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Response.Marshal(b, m, deterministic) -} -func (dst *Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_Response.Merge(dst, src) -} -func (m *Response) XXX_Size() int { - return xxx_messageInfo_Response.Size(m) -} -func (m *Response) XXX_DiscardUnknown() { - xxx_messageInfo_Response.DiscardUnknown(m) -} - -var xxx_messageInfo_Response proto.InternalMessageInfo - -func (m *Response) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Response) GetSchema() *Schema { - if m != nil { - return m.Schema - } - return nil -} - -// `Info` is a representation of OpenAPI v2 specification's Info object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject -// -// TODO(ivucica): document fields -type Info struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService,proto3" json:"terms_of_service,omitempty"` - Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` - Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Info) Reset() { *m = Info{} } -func (m *Info) String() string { return proto.CompactTextString(m) } -func (*Info) ProtoMessage() {} -func (*Info) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{3} -} -func (m *Info) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Info.Unmarshal(m, b) -} -func (m *Info) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Info.Marshal(b, m, deterministic) -} -func (dst *Info) XXX_Merge(src proto.Message) { - xxx_messageInfo_Info.Merge(dst, src) -} -func (m *Info) XXX_Size() int { - return xxx_messageInfo_Info.Size(m) -} -func (m *Info) XXX_DiscardUnknown() { - xxx_messageInfo_Info.DiscardUnknown(m) -} - -var xxx_messageInfo_Info proto.InternalMessageInfo - -func (m *Info) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *Info) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Info) GetTermsOfService() string { - if m != nil { - return m.TermsOfService - } - return "" -} - -func (m *Info) GetContact() *Contact { - if m != nil { - return m.Contact - } - return nil -} - -func (m *Info) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -// `Contact` is a representation of OpenAPI v2 specification's Contact object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject -// -// TODO(ivucica): document fields -type Contact struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` - Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Contact) Reset() { *m = Contact{} } -func (m *Contact) String() string { return proto.CompactTextString(m) } -func (*Contact) ProtoMessage() {} -func (*Contact) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{4} -} -func (m *Contact) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Contact.Unmarshal(m, b) -} -func (m *Contact) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Contact.Marshal(b, m, deterministic) -} -func (dst *Contact) XXX_Merge(src proto.Message) { - xxx_messageInfo_Contact.Merge(dst, src) -} -func (m *Contact) XXX_Size() int { - return xxx_messageInfo_Contact.Size(m) -} -func (m *Contact) XXX_DiscardUnknown() { - xxx_messageInfo_Contact.DiscardUnknown(m) -} - -var xxx_messageInfo_Contact proto.InternalMessageInfo - -func (m *Contact) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Contact) GetUrl() string { - if m != nil { - return m.Url - } - return "" -} - -func (m *Contact) GetEmail() string { - if m != nil { - return m.Email - } - return "" -} - -// `ExternalDocumentation` is a representation of OpenAPI v2 specification's -// ExternalDocumentation object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject -// -// TODO(ivucica): document fields -type ExternalDocumentation struct { - Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ExternalDocumentation) Reset() { *m = ExternalDocumentation{} } -func (m *ExternalDocumentation) String() string { return proto.CompactTextString(m) } -func (*ExternalDocumentation) ProtoMessage() {} -func (*ExternalDocumentation) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{5} -} -func (m *ExternalDocumentation) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ExternalDocumentation.Unmarshal(m, b) -} -func (m *ExternalDocumentation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ExternalDocumentation.Marshal(b, m, deterministic) -} -func (dst *ExternalDocumentation) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExternalDocumentation.Merge(dst, src) -} -func (m *ExternalDocumentation) XXX_Size() int { - return xxx_messageInfo_ExternalDocumentation.Size(m) -} -func (m *ExternalDocumentation) XXX_DiscardUnknown() { - xxx_messageInfo_ExternalDocumentation.DiscardUnknown(m) -} - -var xxx_messageInfo_ExternalDocumentation proto.InternalMessageInfo - -func (m *ExternalDocumentation) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *ExternalDocumentation) GetUrl() string { - if m != nil { - return m.Url - } - return "" -} - -// `Schema` is a representation of OpenAPI v2 specification's Schema object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject -// -// TODO(ivucica): document fields -type Schema struct { - JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` - Discriminator string `protobuf:"bytes,2,opt,name=discriminator,proto3" json:"discriminator,omitempty"` - ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` - Example *any.Any `protobuf:"bytes,6,opt,name=example,proto3" json:"example,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Schema) Reset() { *m = Schema{} } -func (m *Schema) String() string { return proto.CompactTextString(m) } -func (*Schema) ProtoMessage() {} -func (*Schema) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{6} -} -func (m *Schema) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Schema.Unmarshal(m, b) -} -func (m *Schema) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Schema.Marshal(b, m, deterministic) -} -func (dst *Schema) XXX_Merge(src proto.Message) { - xxx_messageInfo_Schema.Merge(dst, src) -} -func (m *Schema) XXX_Size() int { - return xxx_messageInfo_Schema.Size(m) -} -func (m *Schema) XXX_DiscardUnknown() { - xxx_messageInfo_Schema.DiscardUnknown(m) -} - -var xxx_messageInfo_Schema proto.InternalMessageInfo - -func (m *Schema) GetJsonSchema() *JSONSchema { - if m != nil { - return m.JsonSchema - } - return nil -} - -func (m *Schema) GetDiscriminator() string { - if m != nil { - return m.Discriminator - } - return "" -} - -func (m *Schema) GetReadOnly() bool { - if m != nil { - return m.ReadOnly - } - return false -} - -func (m *Schema) GetExternalDocs() *ExternalDocumentation { - if m != nil { - return m.ExternalDocs - } - return nil -} - -func (m *Schema) GetExample() *any.Any { - if m != nil { - return m.Example - } - return nil -} - -// `JSONSchema` represents properties from JSON Schema taken, and as used, in -// the OpenAPI v2 spec. -// -// This includes changes made by OpenAPI v2. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject -// -// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, -// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json -// -// TODO(ivucica): document fields -type JSONSchema struct { - // Ref is used to define an external reference to include in the message. - // This could be a fully qualified proto message reference, and that type must be imported - // into the protofile. If no message is identified, the Ref will be used verbatim in - // the output. - // For example: - // `ref: ".google.protobuf.Timestamp"`. - Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` - Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - Default string `protobuf:"bytes,7,opt,name=default,proto3" json:"default,omitempty"` - MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf,proto3" json:"multiple_of,omitempty"` - Maximum float64 `protobuf:"fixed64,11,opt,name=maximum,proto3" json:"maximum,omitempty"` - ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum,proto3" json:"exclusive_maximum,omitempty"` - Minimum float64 `protobuf:"fixed64,13,opt,name=minimum,proto3" json:"minimum,omitempty"` - ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum,proto3" json:"exclusive_minimum,omitempty"` - MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` - MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` - Pattern string `protobuf:"bytes,17,opt,name=pattern,proto3" json:"pattern,omitempty"` - MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems,proto3" json:"max_items,omitempty"` - MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems,proto3" json:"min_items,omitempty"` - UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems,proto3" json:"unique_items,omitempty"` - MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties,proto3" json:"max_properties,omitempty"` - MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties,proto3" json:"min_properties,omitempty"` - Required []string `protobuf:"bytes,26,rep,name=required,proto3" json:"required,omitempty"` - // Items in 'array' must be unique. - Array []string `protobuf:"bytes,34,rep,name=array,proto3" json:"array,omitempty"` - Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,proto3,enum=grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *JSONSchema) Reset() { *m = JSONSchema{} } -func (m *JSONSchema) String() string { return proto.CompactTextString(m) } -func (*JSONSchema) ProtoMessage() {} -func (*JSONSchema) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{7} -} -func (m *JSONSchema) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_JSONSchema.Unmarshal(m, b) -} -func (m *JSONSchema) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_JSONSchema.Marshal(b, m, deterministic) -} -func (dst *JSONSchema) XXX_Merge(src proto.Message) { - xxx_messageInfo_JSONSchema.Merge(dst, src) -} -func (m *JSONSchema) XXX_Size() int { - return xxx_messageInfo_JSONSchema.Size(m) -} -func (m *JSONSchema) XXX_DiscardUnknown() { - xxx_messageInfo_JSONSchema.DiscardUnknown(m) -} - -var xxx_messageInfo_JSONSchema proto.InternalMessageInfo - -func (m *JSONSchema) GetRef() string { - if m != nil { - return m.Ref - } - return "" -} - -func (m *JSONSchema) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *JSONSchema) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *JSONSchema) GetDefault() string { - if m != nil { - return m.Default - } - return "" -} - -func (m *JSONSchema) GetMultipleOf() float64 { - if m != nil { - return m.MultipleOf - } - return 0 -} - -func (m *JSONSchema) GetMaximum() float64 { - if m != nil { - return m.Maximum - } - return 0 -} - -func (m *JSONSchema) GetExclusiveMaximum() bool { - if m != nil { - return m.ExclusiveMaximum - } - return false -} - -func (m *JSONSchema) GetMinimum() float64 { - if m != nil { - return m.Minimum - } - return 0 -} - -func (m *JSONSchema) GetExclusiveMinimum() bool { - if m != nil { - return m.ExclusiveMinimum - } - return false -} - -func (m *JSONSchema) GetMaxLength() uint64 { - if m != nil { - return m.MaxLength - } - return 0 -} - -func (m *JSONSchema) GetMinLength() uint64 { - if m != nil { - return m.MinLength - } - return 0 -} - -func (m *JSONSchema) GetPattern() string { - if m != nil { - return m.Pattern - } - return "" -} - -func (m *JSONSchema) GetMaxItems() uint64 { - if m != nil { - return m.MaxItems - } - return 0 -} - -func (m *JSONSchema) GetMinItems() uint64 { - if m != nil { - return m.MinItems - } - return 0 -} - -func (m *JSONSchema) GetUniqueItems() bool { - if m != nil { - return m.UniqueItems - } - return false -} - -func (m *JSONSchema) GetMaxProperties() uint64 { - if m != nil { - return m.MaxProperties - } - return 0 -} - -func (m *JSONSchema) GetMinProperties() uint64 { - if m != nil { - return m.MinProperties - } - return 0 -} - -func (m *JSONSchema) GetRequired() []string { - if m != nil { - return m.Required - } - return nil -} - -func (m *JSONSchema) GetArray() []string { - if m != nil { - return m.Array - } - return nil -} - -func (m *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes { - if m != nil { - return m.Type - } - return nil -} - -// `Tag` is a representation of OpenAPI v2 specification's Tag object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject -// -// TODO(ivucica): document fields -type Tag struct { - // TODO(ivucica): Description should be extracted from comments on the proto - // service object. - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Tag) Reset() { *m = Tag{} } -func (m *Tag) String() string { return proto.CompactTextString(m) } -func (*Tag) ProtoMessage() {} -func (*Tag) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{8} -} -func (m *Tag) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Tag.Unmarshal(m, b) -} -func (m *Tag) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Tag.Marshal(b, m, deterministic) -} -func (dst *Tag) XXX_Merge(src proto.Message) { - xxx_messageInfo_Tag.Merge(dst, src) -} -func (m *Tag) XXX_Size() int { - return xxx_messageInfo_Tag.Size(m) -} -func (m *Tag) XXX_DiscardUnknown() { - xxx_messageInfo_Tag.DiscardUnknown(m) -} - -var xxx_messageInfo_Tag proto.InternalMessageInfo - -func (m *Tag) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Tag) GetExternalDocs() *ExternalDocumentation { - if m != nil { - return m.ExternalDocs - } - return nil -} - -// `SecurityDefinitions` is a representation of OpenAPI v2 specification's -// Security Definitions object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject -// -// A declaration of the security schemes available to be used in the -// specification. This does not enforce the security schemes on the operations -// and only serves to provide the relevant details for each scheme. -type SecurityDefinitions struct { - // A single security scheme definition, mapping a "name" to the scheme it defines. - Security map[string]*SecurityScheme `protobuf:"bytes,1,rep,name=security,proto3" json:"security,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SecurityDefinitions) Reset() { *m = SecurityDefinitions{} } -func (m *SecurityDefinitions) String() string { return proto.CompactTextString(m) } -func (*SecurityDefinitions) ProtoMessage() {} -func (*SecurityDefinitions) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{9} -} -func (m *SecurityDefinitions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SecurityDefinitions.Unmarshal(m, b) -} -func (m *SecurityDefinitions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SecurityDefinitions.Marshal(b, m, deterministic) -} -func (dst *SecurityDefinitions) XXX_Merge(src proto.Message) { - xxx_messageInfo_SecurityDefinitions.Merge(dst, src) -} -func (m *SecurityDefinitions) XXX_Size() int { - return xxx_messageInfo_SecurityDefinitions.Size(m) -} -func (m *SecurityDefinitions) XXX_DiscardUnknown() { - xxx_messageInfo_SecurityDefinitions.DiscardUnknown(m) -} - -var xxx_messageInfo_SecurityDefinitions proto.InternalMessageInfo - -func (m *SecurityDefinitions) GetSecurity() map[string]*SecurityScheme { - if m != nil { - return m.Security - } - return nil -} - -// `SecurityScheme` is a representation of OpenAPI v2 specification's -// Security Scheme object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject -// -// Allows the definition of a security scheme that can be used by the -// operations. Supported schemes are basic authentication, an API key (either as -// a header or as a query parameter) and OAuth2's common flows (implicit, -// password, application and access code). -type SecurityScheme struct { - // Required. The type of the security scheme. Valid values are "basic", - // "apiKey" or "oauth2". - Type SecurityScheme_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Type" json:"type,omitempty"` - // A short description for security scheme. - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - // Required. The name of the header or query parameter to be used. - // - // Valid for apiKey. - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - // Required. The location of the API key. Valid values are "query" or "header". - // - // Valid for apiKey. - In SecurityScheme_In `protobuf:"varint,4,opt,name=in,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_In" json:"in,omitempty"` - // Required. The flow used by the OAuth2 security scheme. Valid values are - // "implicit", "password", "application" or "accessCode". - // - // Valid for oauth2. - Flow SecurityScheme_Flow `protobuf:"varint,5,opt,name=flow,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Flow" json:"flow,omitempty"` - // Required. The authorization URL to be used for this flow. This SHOULD be in - // the form of a URL. - // - // Valid for oauth2/implicit and oauth2/accessCode. - AuthorizationUrl string `protobuf:"bytes,6,opt,name=authorization_url,json=authorizationUrl,proto3" json:"authorization_url,omitempty"` - // Required. The token URL to be used for this flow. This SHOULD be in the - // form of a URL. - // - // Valid for oauth2/password, oauth2/application and oauth2/accessCode. - TokenUrl string `protobuf:"bytes,7,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"` - // Required. The available scopes for the OAuth2 security scheme. - // - // Valid for oauth2. - Scopes *Scopes `protobuf:"bytes,8,opt,name=scopes,proto3" json:"scopes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SecurityScheme) Reset() { *m = SecurityScheme{} } -func (m *SecurityScheme) String() string { return proto.CompactTextString(m) } -func (*SecurityScheme) ProtoMessage() {} -func (*SecurityScheme) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{10} -} -func (m *SecurityScheme) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SecurityScheme.Unmarshal(m, b) -} -func (m *SecurityScheme) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SecurityScheme.Marshal(b, m, deterministic) -} -func (dst *SecurityScheme) XXX_Merge(src proto.Message) { - xxx_messageInfo_SecurityScheme.Merge(dst, src) -} -func (m *SecurityScheme) XXX_Size() int { - return xxx_messageInfo_SecurityScheme.Size(m) -} -func (m *SecurityScheme) XXX_DiscardUnknown() { - xxx_messageInfo_SecurityScheme.DiscardUnknown(m) -} - -var xxx_messageInfo_SecurityScheme proto.InternalMessageInfo - -func (m *SecurityScheme) GetType() SecurityScheme_Type { - if m != nil { - return m.Type - } - return SecurityScheme_TYPE_INVALID -} - -func (m *SecurityScheme) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *SecurityScheme) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *SecurityScheme) GetIn() SecurityScheme_In { - if m != nil { - return m.In - } - return SecurityScheme_IN_INVALID -} - -func (m *SecurityScheme) GetFlow() SecurityScheme_Flow { - if m != nil { - return m.Flow - } - return SecurityScheme_FLOW_INVALID -} - -func (m *SecurityScheme) GetAuthorizationUrl() string { - if m != nil { - return m.AuthorizationUrl - } - return "" -} - -func (m *SecurityScheme) GetTokenUrl() string { - if m != nil { - return m.TokenUrl - } - return "" -} - -func (m *SecurityScheme) GetScopes() *Scopes { - if m != nil { - return m.Scopes - } - return nil -} - -// `SecurityRequirement` is a representation of OpenAPI v2 specification's -// Security Requirement object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject -// -// Lists the required security schemes to execute this operation. The object can -// have multiple security schemes declared in it which are all required (that -// is, there is a logical AND between the schemes). -// -// The name used for each property MUST correspond to a security scheme -// declared in the Security Definitions. -type SecurityRequirement struct { - // Each name must correspond to a security scheme which is declared in - // the Security Definitions. If the security scheme is of type "oauth2", - // then the value is a list of scope names required for the execution. - // For other security scheme types, the array MUST be empty. - SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue `protobuf:"bytes,1,rep,name=security_requirement,json=securityRequirement,proto3" json:"security_requirement,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SecurityRequirement) Reset() { *m = SecurityRequirement{} } -func (m *SecurityRequirement) String() string { return proto.CompactTextString(m) } -func (*SecurityRequirement) ProtoMessage() {} -func (*SecurityRequirement) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{11} -} -func (m *SecurityRequirement) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SecurityRequirement.Unmarshal(m, b) -} -func (m *SecurityRequirement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SecurityRequirement.Marshal(b, m, deterministic) -} -func (dst *SecurityRequirement) XXX_Merge(src proto.Message) { - xxx_messageInfo_SecurityRequirement.Merge(dst, src) -} -func (m *SecurityRequirement) XXX_Size() int { - return xxx_messageInfo_SecurityRequirement.Size(m) -} -func (m *SecurityRequirement) XXX_DiscardUnknown() { - xxx_messageInfo_SecurityRequirement.DiscardUnknown(m) -} - -var xxx_messageInfo_SecurityRequirement proto.InternalMessageInfo - -func (m *SecurityRequirement) GetSecurityRequirement() map[string]*SecurityRequirement_SecurityRequirementValue { - if m != nil { - return m.SecurityRequirement - } - return nil -} - -// If the security scheme is of type "oauth2", then the value is a list of -// scope names required for the execution. For other security scheme types, -// the array MUST be empty. -type SecurityRequirement_SecurityRequirementValue struct { - Scope []string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SecurityRequirement_SecurityRequirementValue) Reset() { - *m = SecurityRequirement_SecurityRequirementValue{} -} -func (m *SecurityRequirement_SecurityRequirementValue) String() string { - return proto.CompactTextString(m) -} -func (*SecurityRequirement_SecurityRequirementValue) ProtoMessage() {} -func (*SecurityRequirement_SecurityRequirementValue) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{11, 0} -} -func (m *SecurityRequirement_SecurityRequirementValue) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Unmarshal(m, b) -} -func (m *SecurityRequirement_SecurityRequirementValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Marshal(b, m, deterministic) -} -func (dst *SecurityRequirement_SecurityRequirementValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Merge(dst, src) -} -func (m *SecurityRequirement_SecurityRequirementValue) XXX_Size() int { - return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Size(m) -} -func (m *SecurityRequirement_SecurityRequirementValue) XXX_DiscardUnknown() { - xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.DiscardUnknown(m) -} - -var xxx_messageInfo_SecurityRequirement_SecurityRequirementValue proto.InternalMessageInfo - -func (m *SecurityRequirement_SecurityRequirementValue) GetScope() []string { - if m != nil { - return m.Scope - } - return nil -} - -// `Scopes` is a representation of OpenAPI v2 specification's Scopes object. -// -// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject -// -// Lists the available scopes for an OAuth2 security scheme. -type Scopes struct { - // Maps between a name of a scope to a short description of it (as the value - // of the property). - Scope map[string]string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Scopes) Reset() { *m = Scopes{} } -func (m *Scopes) String() string { return proto.CompactTextString(m) } -func (*Scopes) ProtoMessage() {} -func (*Scopes) Descriptor() ([]byte, []int) { - return fileDescriptor_openapiv2_5363312922dcb572, []int{12} -} -func (m *Scopes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Scopes.Unmarshal(m, b) -} -func (m *Scopes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Scopes.Marshal(b, m, deterministic) -} -func (dst *Scopes) XXX_Merge(src proto.Message) { - xxx_messageInfo_Scopes.Merge(dst, src) -} -func (m *Scopes) XXX_Size() int { - return xxx_messageInfo_Scopes.Size(m) -} -func (m *Scopes) XXX_DiscardUnknown() { - xxx_messageInfo_Scopes.DiscardUnknown(m) -} - -var xxx_messageInfo_Scopes proto.InternalMessageInfo - -func (m *Scopes) GetScope() map[string]string { - if m != nil { - return m.Scope - } - return nil -} - -func init() { - proto.RegisterType((*Swagger)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger") - proto.RegisterMapType((map[string]*Response)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger.ResponsesEntry") - proto.RegisterType((*Operation)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation") - proto.RegisterMapType((map[string]*Response)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation.ResponsesEntry") - proto.RegisterType((*Response)(nil), "grpc.gateway.protoc_gen_swagger.options.Response") - proto.RegisterType((*Info)(nil), "grpc.gateway.protoc_gen_swagger.options.Info") - proto.RegisterType((*Contact)(nil), "grpc.gateway.protoc_gen_swagger.options.Contact") - proto.RegisterType((*ExternalDocumentation)(nil), "grpc.gateway.protoc_gen_swagger.options.ExternalDocumentation") - proto.RegisterType((*Schema)(nil), "grpc.gateway.protoc_gen_swagger.options.Schema") - proto.RegisterType((*JSONSchema)(nil), "grpc.gateway.protoc_gen_swagger.options.JSONSchema") - proto.RegisterType((*Tag)(nil), "grpc.gateway.protoc_gen_swagger.options.Tag") - proto.RegisterType((*SecurityDefinitions)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityDefinitions") - proto.RegisterMapType((map[string]*SecurityScheme)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityDefinitions.SecurityEntry") - proto.RegisterType((*SecurityScheme)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityScheme") - proto.RegisterType((*SecurityRequirement)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityRequirement") - proto.RegisterMapType((map[string]*SecurityRequirement_SecurityRequirementValue)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityRequirement.SecurityRequirementEntry") - proto.RegisterType((*SecurityRequirement_SecurityRequirementValue)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityRequirement.SecurityRequirementValue") - proto.RegisterType((*Scopes)(nil), "grpc.gateway.protoc_gen_swagger.options.Scopes") - proto.RegisterMapType((map[string]string)(nil), "grpc.gateway.protoc_gen_swagger.options.Scopes.ScopeEntry") - proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme", Swagger_SwaggerScheme_name, Swagger_SwaggerScheme_value) - proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes", JSONSchema_JSONSchemaSimpleTypes_name, JSONSchema_JSONSchemaSimpleTypes_value) - proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Type", SecurityScheme_Type_name, SecurityScheme_Type_value) - proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.SecurityScheme_In", SecurityScheme_In_name, SecurityScheme_In_value) - proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Flow", SecurityScheme_Flow_name, SecurityScheme_Flow_value) -} - -func init() { - proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", fileDescriptor_openapiv2_5363312922dcb572) -} - -var fileDescriptor_openapiv2_5363312922dcb572 = []byte{ - // 1753 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x5f, 0x73, 0xdb, 0xc6, - 0x11, 0x0f, 0x48, 0x90, 0x04, 0x97, 0x22, 0x73, 0x3e, 0xcb, 0x2d, 0xa2, 0xc4, 0xae, 0xc2, 0xa6, - 0x53, 0x8d, 0x3d, 0xa6, 0x12, 0xe5, 0xa1, 0x99, 0x4c, 0xa7, 0x1d, 0x4a, 0x62, 0x6c, 0xc0, 0x32, - 0xc9, 0x82, 0x54, 0x14, 0x77, 0x26, 0x83, 0x81, 0xc1, 0x23, 0x85, 0x18, 0x38, 0x20, 0xf8, 0x23, - 0x89, 0x7d, 0xeb, 0x4b, 0xdb, 0xe7, 0x4e, 0x5f, 0xfb, 0x31, 0xfa, 0xd6, 0x8f, 0xd1, 0x4f, 0xd2, - 0x7e, 0x80, 0x76, 0xee, 0x0f, 0x48, 0x50, 0x62, 0x32, 0x94, 0xff, 0xf4, 0x89, 0xb7, 0xbf, 0xfd, - 0x73, 0xbb, 0x77, 0xbb, 0x7b, 0x0b, 0xc2, 0xc3, 0x28, 0x0e, 0xd3, 0xd0, 0x7d, 0x3c, 0x23, 0xf4, - 0x71, 0x72, 0xe9, 0xcc, 0x66, 0x24, 0xde, 0x0f, 0xa3, 0xd4, 0x0b, 0x69, 0xb2, 0x1f, 0x46, 0x84, - 0x3a, 0x91, 0x77, 0x71, 0xd0, 0xe1, 0x42, 0xf8, 0x97, 0xb3, 0x38, 0x72, 0x3b, 0x33, 0x27, 0x25, - 0x97, 0xce, 0x5c, 0x60, 0xae, 0x3d, 0x23, 0xd4, 0x96, 0x8a, 0x1d, 0xa9, 0xb8, 0xf3, 0xc1, 0x2c, - 0x0c, 0x67, 0x3e, 0xd9, 0xe7, 0x22, 0x2f, 0xb3, 0xe9, 0xbe, 0x43, 0xa5, 0x7c, 0xfb, 0xbf, 0x55, - 0xa8, 0x8d, 0x84, 0x38, 0xd6, 0xa1, 0x26, 0x35, 0x75, 0x65, 0x57, 0xd9, 0xab, 0x5b, 0x39, 0x89, - 0xbb, 0xa0, 0x7a, 0x74, 0x1a, 0xea, 0xa5, 0x5d, 0x65, 0xaf, 0x71, 0xf0, 0xb8, 0xb3, 0xe1, 0xc6, - 0x1d, 0x83, 0x4e, 0x43, 0x8b, 0xab, 0x62, 0x0c, 0xea, 0x79, 0x98, 0xa4, 0x7a, 0x99, 0x5b, 0xe6, - 0x6b, 0xfc, 0x21, 0xd4, 0x5f, 0x3a, 0x09, 0xb1, 0x23, 0x27, 0x3d, 0xd7, 0x55, 0xce, 0xd0, 0x18, - 0x30, 0x74, 0xd2, 0x73, 0xfc, 0x0d, 0xd4, 0x12, 0xf7, 0x9c, 0x04, 0x24, 0xd1, 0x2b, 0xbb, 0xe5, - 0xbd, 0xd6, 0xc1, 0x6f, 0x36, 0xde, 0x56, 0x06, 0x94, 0xff, 0x8e, 0xb8, 0x19, 0x2b, 0x37, 0x87, - 0x77, 0x40, 0x73, 0x43, 0x9a, 0x64, 0xcc, 0x74, 0x75, 0xb7, 0xcc, 0x76, 0xcd, 0x69, 0xc6, 0x8b, - 0xe2, 0x70, 0x92, 0xb9, 0x24, 0xd1, 0x6b, 0x82, 0x97, 0xd3, 0xf8, 0x5b, 0xa8, 0xc7, 0x24, 0x89, - 0x42, 0x9a, 0x90, 0x44, 0x87, 0xdd, 0xf2, 0x5e, 0xe3, 0xe0, 0xb7, 0xb7, 0xf6, 0xc9, 0xca, 0x2d, - 0xf4, 0x68, 0x1a, 0xcf, 0xad, 0xa5, 0x45, 0x1c, 0xc2, 0x76, 0x42, 0xdc, 0x2c, 0xf6, 0xd2, 0xb9, - 0x3d, 0x21, 0x53, 0x8f, 0x7a, 0x5c, 0x53, 0x6f, 0xf0, 0x43, 0xff, 0xf5, 0xe6, 0x3b, 0x49, 0x23, - 0xc7, 0x4b, 0x1b, 0xd6, 0xdd, 0xe4, 0x26, 0x88, 0xbf, 0x01, 0x2d, 0x87, 0xf5, 0x2d, 0x1e, 0xce, - 0xed, 0x37, 0xb1, 0xc8, 0xf7, 0x99, 0x17, 0x93, 0x80, 0xd0, 0xd4, 0x5a, 0x58, 0xc3, 0x2e, 0x34, - 0xc9, 0x55, 0x4a, 0x62, 0xea, 0xf8, 0xf6, 0x24, 0x74, 0x13, 0xbd, 0xc5, 0x63, 0xd8, 0xfc, 0x06, - 0x7b, 0x52, 0xfb, 0x38, 0x74, 0x33, 0x66, 0xdb, 0x61, 0xb0, 0xb5, 0x45, 0x96, 0x70, 0xb2, 0x13, - 0x42, 0x6b, 0xf5, 0x30, 0x31, 0x82, 0xf2, 0x2b, 0x32, 0x97, 0xc9, 0xcb, 0x96, 0xf8, 0x09, 0x54, - 0x2e, 0x1c, 0x3f, 0x23, 0x32, 0x73, 0x3f, 0xdb, 0xd8, 0x81, 0xdc, 0xb2, 0x25, 0xf4, 0xbf, 0x2c, - 0x7d, 0xa1, 0xb4, 0x0f, 0xa1, 0xb9, 0x92, 0x51, 0xb8, 0x01, 0xb5, 0xd3, 0xfe, 0xb3, 0xfe, 0xe0, - 0xac, 0x8f, 0xde, 0xc3, 0x1a, 0xa8, 0x4f, 0xc7, 0xe3, 0x21, 0x52, 0x70, 0x1d, 0x2a, 0x6c, 0x35, - 0x42, 0x25, 0x5c, 0x85, 0xd2, 0xd9, 0x08, 0x95, 0x71, 0x0d, 0xca, 0x67, 0xa3, 0x11, 0x52, 0x4d, - 0x55, 0xd3, 0x50, 0xdd, 0x54, 0xb5, 0x3a, 0x02, 0x53, 0xd5, 0x9a, 0xa8, 0xd5, 0xfe, 0x73, 0x05, - 0xea, 0x83, 0x88, 0xc4, 0x3c, 0x44, 0x56, 0x26, 0xa9, 0x33, 0x4b, 0x74, 0x85, 0xe7, 0x1e, 0x5f, - 0xf3, 0xba, 0xcc, 0x82, 0xc0, 0x89, 0xe7, 0x3c, 0x0c, 0x56, 0x97, 0x82, 0xc4, 0xbb, 0xd0, 0x98, - 0x90, 0xc4, 0x8d, 0x3d, 0xee, 0xb5, 0xac, 0xad, 0x22, 0x74, 0xf3, 0x26, 0xd4, 0xb7, 0x7f, 0x13, - 0xf8, 0x63, 0xd8, 0x0a, 0xf3, 0x08, 0x6c, 0x6f, 0xa2, 0x57, 0x84, 0x1f, 0x0b, 0xcc, 0x98, 0xbc, - 0x76, 0xcd, 0xd9, 0xc5, 0x9a, 0xab, 0xf3, 0x24, 0xed, 0x6e, 0xec, 0xfb, 0xe2, 0x58, 0x7f, 0xa4, - 0xea, 0xf4, 0x65, 0x9b, 0x01, 0xbe, 0xf7, 0xa2, 0x4d, 0x3c, 0x00, 0x98, 0x90, 0x28, 0x26, 0xae, - 0x93, 0x92, 0x09, 0xaf, 0x42, 0xcd, 0x2a, 0x20, 0xef, 0xae, 0x7c, 0xfe, 0xef, 0x99, 0x2d, 0xb2, - 0xb2, 0xfd, 0x47, 0x05, 0xb4, 0x9c, 0x7b, 0x3d, 0xb5, 0x94, 0x9b, 0xa9, 0xf5, 0x04, 0xaa, 0xfc, - 0xa8, 0x1c, 0xe9, 0xc2, 0xfe, 0xe6, 0xd1, 0x73, 0x35, 0x4b, 0xaa, 0x9b, 0xaa, 0x56, 0xe6, 0x95, - 0xa1, 0xa2, 0x4a, 0xfb, 0x5f, 0x0a, 0xa8, 0xec, 0xd5, 0xc0, 0xdb, 0x50, 0x49, 0xbd, 0xd4, 0x27, - 0x72, 0x67, 0x41, 0x5c, 0xf7, 0xaa, 0x74, 0xd3, 0xab, 0x3d, 0x40, 0x29, 0x89, 0x83, 0xc4, 0x0e, - 0xa7, 0x76, 0x42, 0xe2, 0x0b, 0xcf, 0x25, 0xb2, 0x2e, 0x5a, 0x1c, 0x1f, 0x4c, 0x47, 0x02, 0xc5, - 0x26, 0xd4, 0xdc, 0x90, 0xa6, 0x8e, 0x9b, 0xca, 0xa2, 0xf8, 0x74, 0xe3, 0x00, 0x8e, 0x84, 0x9e, - 0x95, 0x1b, 0x60, 0x59, 0x74, 0x41, 0xe2, 0x84, 0xf9, 0x54, 0x15, 0x25, 0x2a, 0x49, 0x53, 0xd5, - 0x2a, 0xa8, 0xda, 0xee, 0x41, 0x4d, 0xea, 0xb0, 0x0a, 0xa7, 0x4e, 0x90, 0xc7, 0xc5, 0xd7, 0xec, - 0x7a, 0xb3, 0xd8, 0x97, 0xe1, 0xb0, 0x25, 0x0b, 0x9f, 0x04, 0x8e, 0xe7, 0x4b, 0xdf, 0x05, 0xd1, - 0x7e, 0x06, 0xf7, 0xd6, 0xd6, 0xe3, 0x06, 0xb7, 0x75, 0x63, 0x8b, 0xf6, 0x3f, 0x4b, 0x50, 0x15, - 0x37, 0x81, 0xc7, 0xd0, 0xf8, 0x2e, 0x09, 0xa9, 0x2d, 0xef, 0x53, 0xe1, 0xc7, 0xf1, 0xf9, 0xc6, - 0xc7, 0x61, 0x8e, 0x06, 0x7d, 0x79, 0xa7, 0xc0, 0xec, 0x48, 0xab, 0x9f, 0x40, 0x73, 0xe2, 0x31, - 0x0f, 0x02, 0x8f, 0x3a, 0x69, 0x18, 0xcb, 0xcd, 0x57, 0x41, 0x36, 0x04, 0xc4, 0xc4, 0x99, 0xd8, - 0x21, 0xf5, 0xe7, 0x3c, 0x5a, 0xcd, 0xd2, 0x18, 0x30, 0xa0, 0xfe, 0x9a, 0x87, 0xa4, 0xf2, 0x0e, - 0xda, 0x57, 0x07, 0x6a, 0xe4, 0xca, 0x09, 0x22, 0x9f, 0xf0, 0xcb, 0x6b, 0x1c, 0x6c, 0x77, 0xc4, - 0xc0, 0xd4, 0xc9, 0x07, 0xa6, 0x4e, 0x97, 0xce, 0xad, 0x5c, 0x48, 0x66, 0xea, 0x9f, 0x6a, 0x00, - 0xcb, 0xc0, 0xd9, 0xf9, 0xc6, 0x64, 0x2a, 0xaf, 0x8b, 0x2d, 0x97, 0x19, 0x5c, 0xf9, 0x91, 0x0c, - 0xae, 0xde, 0xbc, 0x29, 0x1d, 0x6a, 0x13, 0x32, 0x75, 0x32, 0x3f, 0xd5, 0x6b, 0x22, 0x97, 0x24, - 0x89, 0x7f, 0x06, 0x8d, 0x20, 0xf3, 0x53, 0x2f, 0xf2, 0x89, 0x1d, 0x4e, 0x75, 0xd8, 0x55, 0xf6, - 0x14, 0x0b, 0x72, 0x68, 0x30, 0x65, 0xaa, 0x81, 0x73, 0xe5, 0x05, 0x59, 0xc0, 0xfb, 0x95, 0x62, - 0xe5, 0x24, 0x7e, 0x04, 0x77, 0xc8, 0x95, 0xeb, 0x67, 0x89, 0x77, 0x41, 0xec, 0x5c, 0x66, 0x8b, - 0x9f, 0x36, 0x5a, 0x30, 0x9e, 0x4b, 0x61, 0x66, 0xc6, 0xa3, 0x5c, 0xa4, 0x29, 0xcd, 0x08, 0xf2, - 0x9a, 0x19, 0x29, 0xd3, 0xba, 0x6e, 0x46, 0x0a, 0xdf, 0x07, 0x08, 0x9c, 0x2b, 0xdb, 0x27, 0x74, - 0x96, 0x9e, 0xeb, 0xef, 0xef, 0x2a, 0x7b, 0xaa, 0x55, 0x0f, 0x9c, 0xab, 0x13, 0x0e, 0x70, 0xb6, - 0x47, 0x73, 0x36, 0x92, 0x6c, 0x8f, 0x4a, 0xb6, 0x0e, 0xb5, 0xc8, 0x49, 0xd9, 0x35, 0xe9, 0x77, - 0xc4, 0x31, 0x48, 0x92, 0x65, 0x0c, 0xb3, 0xeb, 0xa5, 0x24, 0x48, 0xf4, 0x6d, 0xae, 0xa7, 0x05, - 0xce, 0x95, 0xc1, 0x68, 0xce, 0xf4, 0xa8, 0x64, 0xde, 0x93, 0x4c, 0x8f, 0x0a, 0xe6, 0xc7, 0xb0, - 0x95, 0x51, 0xef, 0xfb, 0x8c, 0x48, 0xfe, 0x4f, 0xb8, 0xe7, 0x0d, 0x81, 0x09, 0x91, 0x5f, 0x40, - 0x8b, 0x19, 0x8f, 0x62, 0xf6, 0x7a, 0xa5, 0x1e, 0x49, 0x74, 0x9d, 0x1b, 0x69, 0x06, 0xce, 0xd5, - 0x70, 0x01, 0x72, 0x31, 0x8f, 0x16, 0xc5, 0x3e, 0x90, 0x62, 0x1e, 0x2d, 0x88, 0xed, 0x80, 0x16, - 0x8b, 0x16, 0x3f, 0xd1, 0x77, 0xc4, 0xd3, 0x96, 0xd3, 0x2c, 0x3f, 0x9c, 0x38, 0x76, 0xe6, 0x7a, - 0x9b, 0x33, 0x04, 0x81, 0xbf, 0x05, 0x35, 0x9d, 0x47, 0x44, 0xff, 0x39, 0x9f, 0x79, 0x8d, 0xd7, - 0xa8, 0xc1, 0xc2, 0x72, 0xe4, 0xb1, 0x84, 0x1d, 0xcf, 0x23, 0x92, 0x58, 0xdc, 0x6c, 0xfb, 0x12, - 0xee, 0xad, 0x65, 0xaf, 0xce, 0x32, 0x75, 0xa8, 0x74, 0x2d, 0xab, 0xfb, 0x02, 0x29, 0x0c, 0x3f, - 0x1c, 0x0c, 0x4e, 0x7a, 0xdd, 0x3e, 0x2a, 0x31, 0xc2, 0xe8, 0x8f, 0x7b, 0x4f, 0x7a, 0x16, 0x2a, - 0xb3, 0x81, 0xa7, 0x7f, 0x7a, 0x72, 0x82, 0x54, 0x0c, 0x50, 0xed, 0x9f, 0x3e, 0x3f, 0xec, 0x59, - 0xa8, 0xc2, 0xd6, 0x83, 0x43, 0xb3, 0x77, 0x34, 0x46, 0x55, 0xb6, 0x1e, 0x8d, 0x2d, 0xa3, 0xff, - 0x04, 0xd5, 0x4c, 0x55, 0x53, 0x50, 0xc9, 0x54, 0xb5, 0x12, 0x2a, 0x8b, 0x02, 0xba, 0x36, 0x0a, - 0x61, 0x74, 0xd7, 0x54, 0xb5, 0xbb, 0x68, 0xdb, 0x54, 0xb5, 0x9f, 0x22, 0xdd, 0x54, 0xb5, 0x0f, - 0xd1, 0x47, 0xa6, 0xaa, 0x7d, 0x84, 0xee, 0x9b, 0xaa, 0x76, 0x1f, 0x3d, 0x30, 0x55, 0xed, 0x01, - 0x6a, 0x9b, 0xaa, 0xf6, 0x09, 0x7a, 0x68, 0xaa, 0xda, 0x43, 0xf4, 0xc8, 0x54, 0xb5, 0x47, 0xa8, - 0xd3, 0xfe, 0xab, 0x02, 0xe5, 0xb1, 0x33, 0xdb, 0xe0, 0x6d, 0xb8, 0xd1, 0x4d, 0xca, 0x6f, 0xbf, - 0x9b, 0x88, 0x40, 0xdb, 0xff, 0x51, 0xe0, 0xee, 0x9a, 0x41, 0x1c, 0x4f, 0x0b, 0x43, 0x83, 0xc2, - 0x87, 0x06, 0xf3, 0x4d, 0x06, 0xfb, 0x05, 0x26, 0xe6, 0x9a, 0xe5, 0x08, 0x91, 0x42, 0x73, 0x85, - 0xb5, 0x66, 0x82, 0x78, 0xbe, 0x3a, 0x41, 0xfc, 0xea, 0xd6, 0x7e, 0xc8, 0xef, 0xaa, 0xc2, 0x84, - 0xfc, 0x8f, 0x0a, 0xb4, 0x56, 0xb9, 0x78, 0x28, 0xf3, 0x99, 0x6d, 0xdc, 0x7a, 0x8d, 0x09, 0x49, - 0x98, 0xe9, 0xb0, 0x24, 0x15, 0x29, 0xbc, 0xc1, 0x3d, 0xe7, 0x4f, 0x6c, 0xb9, 0xf0, 0xc4, 0x9a, - 0x50, 0xf2, 0x28, 0x7f, 0xe8, 0x5b, 0x07, 0x5f, 0xbe, 0xae, 0x17, 0x06, 0xb5, 0x4a, 0x1e, 0x65, - 0x31, 0x4d, 0xfd, 0xf0, 0x92, 0x37, 0xf6, 0x37, 0x88, 0xe9, 0x2b, 0x3f, 0xbc, 0xb4, 0xb8, 0x25, - 0xd6, 0x57, 0x9d, 0x2c, 0x3d, 0x0f, 0x63, 0xef, 0x0f, 0x62, 0x8a, 0x66, 0x6f, 0xb5, 0x78, 0x1b, - 0xd0, 0x0a, 0xe3, 0x34, 0xf6, 0x59, 0x8b, 0x4b, 0xc3, 0x57, 0x44, 0x08, 0x89, 0x27, 0x42, 0xe3, - 0x00, 0x63, 0xf2, 0xa9, 0x2c, 0x8c, 0x48, 0xa2, 0x6b, 0xb7, 0x9e, 0xca, 0x98, 0x9a, 0x25, 0xd5, - 0xdb, 0xcf, 0x40, 0x65, 0x87, 0x8e, 0x11, 0x6c, 0x8d, 0x5f, 0x0c, 0x7b, 0xb6, 0xd1, 0xff, 0xba, - 0x7b, 0x62, 0x1c, 0xa3, 0xf7, 0x70, 0x0b, 0x80, 0x23, 0x87, 0xdd, 0x91, 0x71, 0x84, 0x94, 0x85, - 0x44, 0x77, 0x68, 0xd8, 0xcf, 0x7a, 0x2f, 0x50, 0x09, 0xbf, 0x0f, 0x0d, 0x8e, 0x0c, 0xba, 0xa7, - 0xe3, 0xa7, 0x07, 0xa8, 0xdc, 0xfe, 0x0c, 0x4a, 0x06, 0x65, 0x8a, 0x46, 0xbf, 0x60, 0x68, 0x0b, - 0x34, 0xa3, 0x6f, 0xff, 0xee, 0xb4, 0x67, 0xb1, 0x4e, 0xd3, 0x84, 0xba, 0xd1, 0xb7, 0x9f, 0xf6, - 0xba, 0xc7, 0x3d, 0x0b, 0x95, 0xda, 0xdf, 0x81, 0xca, 0x0e, 0x88, 0x59, 0xff, 0xea, 0x64, 0x70, - 0x56, 0x50, 0xbb, 0x03, 0x4d, 0x81, 0x3c, 0x1f, 0x9e, 0x18, 0x47, 0xc6, 0x18, 0x29, 0x0b, 0x68, - 0xd8, 0x1d, 0x8d, 0xce, 0x06, 0xd6, 0x31, 0x2a, 0xe1, 0x6d, 0x40, 0x1c, 0xea, 0x0e, 0x99, 0x54, - 0x77, 0x6c, 0x0c, 0xfa, 0xa8, 0xbc, 0x44, 0x8f, 0x8e, 0x7a, 0xa3, 0x91, 0x7d, 0x34, 0x38, 0xee, - 0x21, 0xb5, 0xfd, 0xef, 0xd2, 0xb2, 0x5a, 0x0b, 0x23, 0x39, 0xfe, 0x8b, 0x52, 0xf8, 0x26, 0x8f, - 0x97, 0x0c, 0x59, 0xba, 0xa7, 0x6f, 0x32, 0xef, 0xaf, 0xc3, 0x44, 0x15, 0x2f, 0x3e, 0xd6, 0x0b, - 0x9c, 0x9d, 0x4f, 0x41, 0x5f, 0xa3, 0xf0, 0x35, 0x2b, 0x3d, 0xf6, 0x92, 0xf0, 0x4b, 0x93, 0x5f, - 0x8d, 0x82, 0xd8, 0xf9, 0xbb, 0xb2, 0x56, 0xe5, 0x87, 0xda, 0xc1, 0xab, 0xd5, 0x76, 0xf0, 0xd6, - 0x63, 0xe3, 0xae, 0x16, 0x9b, 0xc5, 0xdf, 0x14, 0x36, 0x7f, 0xb2, 0x5c, 0xc3, 0xc3, 0x62, 0x00, - 0x8d, 0xdb, 0xd4, 0x27, 0xd7, 0x17, 0x3f, 0xe2, 0xf0, 0x64, 0xf0, 0x5f, 0x00, 0x2c, 0xc1, 0x35, - 0xd1, 0x6e, 0x17, 0xa3, 0xad, 0x17, 0xdc, 0x3a, 0x3c, 0xfa, 0x7d, 0x77, 0xe6, 0xa5, 0xe7, 0xd9, - 0xcb, 0x8e, 0x1b, 0x06, 0xfb, 0xcc, 0x91, 0xc7, 0xc4, 0x0d, 0x93, 0x79, 0x92, 0x12, 0x49, 0x4a, - 0xbf, 0xf6, 0x7f, 0xf8, 0xaf, 0xba, 0x97, 0x55, 0xce, 0xfb, 0xfc, 0x7f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xab, 0x81, 0x5a, 0xfc, 0xcf, 0x13, 0x00, 0x00, -} diff --git a/runtime/internal/stream_chunk.pb.go b/runtime/internal/stream_chunk.pb.go index f4af074808b..dd2d81c72a6 100644 --- a/runtime/internal/stream_chunk.pb.go +++ b/runtime/internal/stream_chunk.pb.go @@ -36,7 +36,7 @@ func (m *StreamError) Reset() { *m = StreamError{} } func (m *StreamError) String() string { return proto.CompactTextString(m) } func (*StreamError) ProtoMessage() {} func (*StreamError) Descriptor() ([]byte, []int) { - return fileDescriptor_stream_chunk_6adb10b40700458b, []int{0} + return fileDescriptor_stream_chunk_72eb5044e9af9066, []int{0} } func (m *StreamError) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StreamError.Unmarshal(m, b) @@ -96,10 +96,10 @@ func init() { } func init() { - proto.RegisterFile("runtime/internal/stream_chunk.proto", fileDescriptor_stream_chunk_6adb10b40700458b) + proto.RegisterFile("runtime/internal/stream_chunk.proto", fileDescriptor_stream_chunk_72eb5044e9af9066) } -var fileDescriptor_stream_chunk_6adb10b40700458b = []byte{ +var fileDescriptor_stream_chunk_72eb5044e9af9066 = []byte{ // 226 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x90, 0xc1, 0x4e, 0x84, 0x30, 0x10, 0x86, 0x83, 0xeb, 0xba, 0xbb, 0xc3, 0x8d, 0xec, 0xa1, 0xea, 0x41, 0xa2, 0x17, 0x4e, 0x25,