diff --git a/samples/client/petstore/go/go-petstore-withXml/.swagger-codegen/VERSION b/samples/client/petstore/go/go-petstore-withXml/.swagger-codegen/VERSION index 855ff9501eb..017674fb59d 100644 --- a/samples/client/petstore/go/go-petstore-withXml/.swagger-codegen/VERSION +++ b/samples/client/petstore/go/go-petstore-withXml/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +2.4.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml b/samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml index 0e8634f5edf..5031bb90c30 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml +++ b/samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml @@ -58,7 +58,6 @@ paths: - petstore_auth: - "write:pets" - "read:pets" - x-is-post-method: true put: tags: - "pet" @@ -90,7 +89,6 @@ paths: - petstore_auth: - "write:pets" - "read:pets" - x-is-put-method: true /pet/findByStatus: get: tags: @@ -109,11 +107,11 @@ paths: type: "array" items: type: "string" - default: "available" enum: - "available" - "pending" - "sold" + default: "available" collectionFormat: "csv" x-exportParamName: "Status" responses: @@ -129,7 +127,6 @@ paths: - petstore_auth: - "write:pets" - "read:pets" - x-is-get-method: true /pet/findByTags: get: tags: @@ -165,7 +162,6 @@ paths: - "write:pets" - "read:pets" deprecated: true - x-is-get-method: true /pet/{petId}: get: tags: @@ -195,7 +191,6 @@ paths: description: "Pet not found" security: - api_key: [] - x-is-get-method: true post: tags: - "pet" @@ -236,7 +231,6 @@ paths: - petstore_auth: - "write:pets" - "read:pets" - x-is-post-method: true delete: tags: - "pet" @@ -267,7 +261,6 @@ paths: - petstore_auth: - "write:pets" - "read:pets" - x-is-delete-method: true /pet/{petId}/uploadImage: post: tags: @@ -309,7 +302,6 @@ paths: - petstore_auth: - "write:pets" - "read:pets" - x-is-post-method: true /store/inventory: get: tags: @@ -330,7 +322,6 @@ paths: format: "int32" security: - api_key: [] - x-is-get-method: true /store/order: post: tags: @@ -356,7 +347,6 @@ paths: $ref: "#/definitions/Order" 400: description: "Invalid Order" - x-is-post-method: true /store/order/{order_id}: get: tags: @@ -387,7 +377,6 @@ paths: description: "Invalid ID supplied" 404: description: "Order not found" - x-is-get-method: true delete: tags: - "store" @@ -410,7 +399,6 @@ paths: description: "Invalid ID supplied" 404: description: "Order not found" - x-is-delete-method: true /user: post: tags: @@ -432,7 +420,6 @@ paths: responses: default: description: "successful operation" - x-is-post-method: true /user/createWithArray: post: tags: @@ -456,7 +443,6 @@ paths: responses: default: description: "successful operation" - x-is-post-method: true /user/createWithList: post: tags: @@ -480,7 +466,6 @@ paths: responses: default: description: "successful operation" - x-is-post-method: true /user/login: get: tags: @@ -520,7 +505,6 @@ paths: type: "string" 400: description: "Invalid username/password supplied" - x-is-get-method: true /user/logout: get: tags: @@ -535,7 +519,6 @@ paths: responses: default: description: "successful operation" - x-is-get-method: true /user/{username}: get: tags: @@ -562,7 +545,6 @@ paths: description: "Invalid username supplied" 404: description: "User not found" - x-is-get-method: true put: tags: - "user" @@ -591,7 +573,6 @@ paths: description: "Invalid user supplied" 404: description: "User not found" - x-is-put-method: true delete: tags: - "user" @@ -613,7 +594,6 @@ paths: description: "Invalid username supplied" 404: description: "User not found" - x-is-delete-method: true /fake_classname_test: patch: tags: @@ -640,7 +620,6 @@ paths: $ref: "#/definitions/Client" security: - api_key_query: [] - x-is-head-method: true /fake: get: tags: @@ -660,10 +639,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumFormStringArray" - name: "enum_form_string" in: "formData" @@ -684,10 +663,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumHeaderStringArray" - name: "enum_header_string" in: "header" @@ -708,10 +687,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumQueryStringArray" - name: "enum_query_string" in: "query" @@ -752,7 +731,6 @@ paths: description: "Invalid request" 404: description: "Not found" - x-is-get-method: true post: tags: - "fake" @@ -891,7 +869,6 @@ paths: description: "User not found" security: - http_basic_test: [] - x-is-post-method: true patch: tags: - "fake" @@ -915,7 +892,6 @@ paths: description: "successful operation" schema: $ref: "#/definitions/Client" - x-is-head-method: true /fake/outer/number: post: tags: @@ -935,7 +911,6 @@ paths: description: "Output number" schema: $ref: "#/definitions/OuterNumber" - x-is-post-method: true /fake/outer/string: post: tags: @@ -955,7 +930,6 @@ paths: description: "Output string" schema: $ref: "#/definitions/OuterString" - x-is-post-method: true /fake/outer/boolean: post: tags: @@ -975,7 +949,6 @@ paths: description: "Output boolean" schema: $ref: "#/definitions/OuterBoolean" - x-is-post-method: true /fake/outer/composite: post: tags: @@ -995,7 +968,6 @@ paths: description: "Output composite" schema: $ref: "#/definitions/OuterComposite" - x-is-post-method: true /fake/jsonFormData: get: tags: @@ -1021,7 +993,6 @@ paths: responses: 200: description: "successful operation" - x-is-get-method: true /fake/inline-additionalProperties: post: tags: @@ -1044,7 +1015,6 @@ paths: responses: 200: description: "successful operation" - x-is-post-method: true /fake/body-with-query-params: put: tags: @@ -1067,7 +1037,6 @@ paths: responses: 200: description: "Success" - x-is-put-method: true /another-fake/dummy: patch: tags: @@ -1092,7 +1061,6 @@ paths: description: "successful operation" schema: $ref: "#/definitions/Client" - x-is-head-method: true securityDefinitions: petstore_auth: type: "oauth2" @@ -1140,12 +1108,12 @@ definitions: xml: name: "Order" example: - petId: 6 - quantity: 1 id: 0 - shipDate: "2000-01-23T04:56:07.000+00:00" + petId: 6 complete: false status: "placed" + quantity: 1 + shipDate: "2000-01-23T04:56:07.000+00:00" Category: type: "object" properties: @@ -1157,8 +1125,8 @@ definitions: xml: name: "Category" example: - name: "name" id: 6 + name: "name" User: type: "object" properties: @@ -1185,14 +1153,14 @@ definitions: xml: name: "User" example: - firstName: "firstName" + id: 0 lastName: "lastName" - password: "password" - userStatus: 6 phone: "phone" - id: 0 - email: "email" username: "username" + email: "email" + userStatus: 6 + firstName: "firstName" + password: "password" Tag: type: "object" properties: @@ -1204,8 +1172,8 @@ definitions: xml: name: "Tag" example: - name: "name" id: 1 + name: "name" Pet: type: "object" required: @@ -1245,20 +1213,20 @@ definitions: xml: name: "Pet" example: - photoUrls: - - "photoUrls" - - "photoUrls" - name: "doggie" + tags: + - id: 1 + name: "name" + - id: 1 + name: "name" id: 0 category: - name: "name" id: 6 - tags: - - name: "name" - id: 1 - - name: "name" - id: 1 + name: "name" status: "available" + name: "doggie" + photoUrls: + - "photoUrls" + - "photoUrls" ApiResponse: type: "object" properties: @@ -1270,9 +1238,9 @@ definitions: message: type: "string" example: + message: "message" code: 0 type: "type" - message: "message" $special[model.name]: properties: $special[property.name]: @@ -1606,8 +1574,8 @@ definitions: my_boolean: $ref: "#/definitions/OuterBoolean" example: - my_string: {} my_number: {} + my_string: {} my_boolean: {} OuterNumber: type: "number" diff --git a/samples/client/petstore/go/go-petstore-withXml/api_default.go b/samples/client/petstore/go/go-petstore-withXml/api_default.go deleted file mode 100644 index e5bcb58c401..00000000000 --- a/samples/client/petstore/go/go-petstore-withXml/api_default.go +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "io/ioutil" - "net/http" - "net/url" - "strings" - "golang.org/x/net/context" -) - -// Linger please -var ( - _ context.Context -) - -type DefaultApiService service - -/* DefaultApiService - * @param ctx context.Context for authentication, logging, tracing, etc. -@param body -@param query -@return */ -func (a *DefaultApiService) TestBodyWithQueryParams(ctx context.Context, body User, query string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/body-with-query-params" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("query", parameterToString(query, "")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/DefaultApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/DefaultApi.md deleted file mode 100644 index ad8c17c6ae1..00000000000 --- a/samples/client/petstore/go/go-petstore-withXml/docs/DefaultApi.md +++ /dev/null @@ -1,36 +0,0 @@ -# \DefaultApi - -All URIs are relative to *http://petstore.swagger.io:80/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**TestBodyWithQueryParams**](DefaultApi.md#TestBodyWithQueryParams) | **Put** /fake/body-with-query-params | - - -# **TestBodyWithQueryParams** -> TestBodyWithQueryParams(ctx, body, query) - - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**User**](User.md)| | - **query** | **string**| | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go b/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go index 4950a03e747..ca1f2daae70 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go @@ -14,7 +14,7 @@ type EnumClass string // List of EnumClass const ( - ABC EnumClass = "_abc" - EFG EnumClass = "-efg" - XYZ EnumClass = "(xyz)" + ABC_EnumClass EnumClass = "_abc" + EFG_EnumClass EnumClass = "-efg" + XYZ_EnumClass EnumClass = "(xyz)" ) diff --git a/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go b/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go index 0e724d17c5c..31ce691a70a 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go @@ -14,7 +14,7 @@ type OuterEnum string // List of OuterEnum const ( - PLACED OuterEnum = "placed" - APPROVED OuterEnum = "approved" - DELIVERED OuterEnum = "delivered" + PLACED_OuterEnum OuterEnum = "placed" + APPROVED_OuterEnum OuterEnum = "approved" + DELIVERED_OuterEnum OuterEnum = "delivered" ) diff --git a/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION b/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION index a6254504e40..017674fb59d 100644 --- a/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION +++ b/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 \ No newline at end of file +2.4.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/additional_properties_class.go b/samples/client/petstore/go/go-petstore/additional_properties_class.go deleted file mode 100644 index ccb515fecaf..00000000000 --- a/samples/client/petstore/go/go-petstore/additional_properties_class.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type AdditionalPropertiesClass struct { - MapProperty map[string]string `json:"map_property,omitempty"` - MapOfMapProperty map[string]map[string]string `json:"map_of_map_property,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/animal.go b/samples/client/petstore/go/go-petstore/animal.go deleted file mode 100644 index d84f714919c..00000000000 --- a/samples/client/petstore/go/go-petstore/animal.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Animal struct { - ClassName string `json:"className"` - Color string `json:"color,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/animal_farm.go b/samples/client/petstore/go/go-petstore/animal_farm.go deleted file mode 100644 index 5314c78829c..00000000000 --- a/samples/client/petstore/go/go-petstore/animal_farm.go +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type AnimalFarm struct { -} diff --git a/samples/client/petstore/go/go-petstore/another_fake_api.go b/samples/client/petstore/go/go-petstore/another_fake_api.go deleted file mode 100644 index b272de10c0b..00000000000 --- a/samples/client/petstore/go/go-petstore/another_fake_api.go +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "encoding/json" -) - -// Linger please -var ( - _ context.Context -) - -type AnotherFakeApiService service - -/* -AnotherFakeApiService To test special tags -To test special tags - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body client model - -@return Client -*/ -func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client) (Client, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Patch") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Client - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/another-fake/dummy" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v Client - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore/api/swagger.yaml b/samples/client/petstore/go/go-petstore/api/swagger.yaml index 23de7d87add..5031bb90c30 100644 --- a/samples/client/petstore/go/go-petstore/api/swagger.yaml +++ b/samples/client/petstore/go/go-petstore/api/swagger.yaml @@ -107,11 +107,11 @@ paths: type: "array" items: type: "string" - default: "available" enum: - "available" - "pending" - "sold" + default: "available" collectionFormat: "csv" x-exportParamName: "Status" responses: @@ -216,12 +216,14 @@ paths: required: false type: "string" x-exportParamName: "Name" + x-optionalDataType: "String" - name: "status" in: "formData" description: "Updated status of the pet" required: false type: "string" x-exportParamName: "Status" + x-optionalDataType: "String" responses: 405: description: "Invalid input" @@ -244,6 +246,7 @@ paths: required: false type: "string" x-exportParamName: "ApiKey" + x-optionalDataType: "String" - name: "petId" in: "path" description: "Pet id to delete" @@ -283,6 +286,7 @@ paths: required: false type: "string" x-exportParamName: "AdditionalMetadata" + x-optionalDataType: "String" - name: "file" in: "formData" description: "file to upload" @@ -488,8 +492,6 @@ paths: responses: 200: description: "successful operation" - schema: - type: "string" headers: X-Rate-Limit: type: "integer" @@ -499,6 +501,8 @@ paths: type: "string" format: "date-time" description: "date in UTC when token expires" + schema: + type: "string" 400: description: "Invalid username/password supplied" /user/logout: @@ -635,10 +639,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumFormStringArray" - name: "enum_form_string" in: "formData" @@ -651,6 +655,7 @@ paths: - "-efg" - "(xyz)" x-exportParamName: "EnumFormString" + x-optionalDataType: "String" - name: "enum_header_string_array" in: "header" description: "Header parameter enum test (string array)" @@ -658,10 +663,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumHeaderStringArray" - name: "enum_header_string" in: "header" @@ -674,6 +679,7 @@ paths: - "-efg" - "(xyz)" x-exportParamName: "EnumHeaderString" + x-optionalDataType: "String" - name: "enum_query_string_array" in: "query" description: "Query parameter enum test (string array)" @@ -681,10 +687,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumQueryStringArray" - name: "enum_query_string" in: "query" @@ -697,6 +703,7 @@ paths: - "-efg" - "(xyz)" x-exportParamName: "EnumQueryString" + x-optionalDataType: "String" - name: "enum_query_integer" in: "query" description: "Query parameter enum test (double)" @@ -707,6 +714,7 @@ paths: - 1 - -2 x-exportParamName: "EnumQueryInteger" + x-optionalDataType: "Int32" - name: "enum_query_double" in: "formData" description: "Query parameter enum test (double)" @@ -717,6 +725,7 @@ paths: - 1.1 - -1.2 x-exportParamName: "EnumQueryDouble" + x-optionalDataType: "Float64" responses: 400: description: "Invalid request" @@ -745,6 +754,7 @@ paths: maximum: 100 minimum: 10 x-exportParamName: "Integer" + x-optionalDataType: "Int32" - name: "int32" in: "formData" description: "None" @@ -754,6 +764,7 @@ paths: minimum: 20 format: "int32" x-exportParamName: "Int32_" + x-optionalDataType: "Int32" - name: "int64" in: "formData" description: "None" @@ -761,6 +772,7 @@ paths: type: "integer" format: "int64" x-exportParamName: "Int64_" + x-optionalDataType: "Int64" - name: "number" in: "formData" description: "None" @@ -777,6 +789,7 @@ paths: maximum: 987.6 format: "float" x-exportParamName: "Float" + x-optionalDataType: "Float32" - name: "double" in: "formData" description: "None" @@ -793,6 +806,7 @@ paths: type: "string" pattern: "/[a-z]/i" x-exportParamName: "String_" + x-optionalDataType: "String" - name: "pattern_without_delimiter" in: "formData" description: "None" @@ -814,6 +828,7 @@ paths: type: "string" format: "binary" x-exportParamName: "Binary" + x-optionalDataType: "String" - name: "date" in: "formData" description: "None" @@ -821,6 +836,7 @@ paths: type: "string" format: "date" x-exportParamName: "Date" + x-optionalDataType: "String" - name: "dateTime" in: "formData" description: "None" @@ -828,6 +844,7 @@ paths: type: "string" format: "date-time" x-exportParamName: "DateTime" + x-optionalDataType: "Time" - name: "password" in: "formData" description: "None" @@ -837,12 +854,14 @@ paths: minLength: 10 format: "password" x-exportParamName: "Password" + x-optionalDataType: "String" - name: "callback" in: "formData" description: "None" required: false type: "string" x-exportParamName: "Callback" + x-optionalDataType: "String" responses: 400: description: "Invalid username supplied" @@ -1086,6 +1105,8 @@ definitions: complete: type: "boolean" default: false + xml: + name: "Order" example: id: 0 petId: 6 @@ -1093,8 +1114,6 @@ definitions: status: "placed" quantity: 1 shipDate: "2000-01-23T04:56:07.000+00:00" - xml: - name: "Order" Category: type: "object" properties: @@ -1103,11 +1122,11 @@ definitions: format: "int64" name: type: "string" + xml: + name: "Category" example: id: 6 name: "name" - xml: - name: "Category" User: type: "object" properties: @@ -1131,6 +1150,8 @@ definitions: type: "integer" format: "int32" description: "User Status" + xml: + name: "User" example: id: 0 lastName: "lastName" @@ -1140,8 +1161,6 @@ definitions: userStatus: 6 firstName: "firstName" password: "password" - xml: - name: "User" Tag: type: "object" properties: @@ -1150,11 +1169,11 @@ definitions: format: "int64" name: type: "string" + xml: + name: "Tag" example: id: 1 name: "name" - xml: - name: "Tag" Pet: type: "object" required: @@ -1191,6 +1210,8 @@ definitions: - "available" - "pending" - "sold" + xml: + name: "Pet" example: tags: - id: 1 @@ -1206,8 +1227,6 @@ definitions: photoUrls: - "photoUrls" - "photoUrls" - xml: - name: "Pet" ApiResponse: type: "object" properties: @@ -1234,9 +1253,9 @@ definitions: return: type: "integer" format: "int32" - description: "Model for testing reserved words" xml: name: "Return" + description: "Model for testing reserved words" Name: required: - "name" @@ -1253,9 +1272,9 @@ definitions: 123Number: type: "integer" readOnly: true - description: "Model for testing model name same as property name" xml: name: "Name" + description: "Model for testing model name same as property name" 200_response: properties: name: @@ -1263,9 +1282,9 @@ definitions: format: "int32" class: type: "string" - description: "Model for testing model name starting with number" xml: name: "Name" + description: "Model for testing model name starting with number" ClassModel: properties: _class: diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go deleted file mode 100644 index 3c0ed8e3d52..00000000000 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -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" - "unicode/utf8" - "strconv" -) - -var ( - jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") -) - -// APIClient manages communication with the Swagger Petstore API v1.0.0 -// In most cases there should be only one, shared, APIClient. -type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. - - // API Services - AnotherFakeApi *AnotherFakeApiService - FakeApi *FakeApiService - FakeClassnameTags123Api *FakeClassnameTags123ApiService - PetApi *PetApiService - StoreApi *StoreApiService - UserApi *UserApiService -} - -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.AnotherFakeApi = (*AnotherFakeApiService)(&c.common) - c.FakeApi = (*FakeApiService)(&c.common) - c.FakeClassnameTags123Api = (*FakeClassnameTags123ApiService)(&c.common) - c.PetApi = (*PetApiService)(&c.common) - c.StoreApi = (*StoreApiService)(&c.common) - c.UserApi = (*UserApiService)(&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 "" - } - if contains(contentTypes, "application/json") { - return "application/json" - } - return contentTypes[0] // use the first content type specified in 'consumes' -} - -// 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) { - return true - } - } - return false -} - -// 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 = "|" - case "ssv": - delimiter = " " - case "tsv": - delimiter = "\t" - case "csv": - delimiter = "," - } - - if reflect.TypeOf(obj).Kind() == reflect.Slice { - return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") - } - - return fmt.Sprintf("%v", obj) -} - -// callAPI do the request. -func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { - return c.cfg.HTTPClient.Do(request) -} - -// Change base path to allow switching to mocks -func (c *APIClient) ChangeBasePath (path string) { - c.cfg.BasePath = path -} - -// 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 url.Values, - fileName string, - 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) - } - } - - // Encode the parameters. - url.RawQuery = query.Encode() - - // 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 parameters, if any - if len(headerParams) > 0 { - headers := http.Header{} - for h, v := range headerParams { - headers.Set(h, v) - } - localVarRequest.Header = headers - } - - // 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) - } - - // 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) - } - } - - for header, value := range c.cfg.DefaultHeader { - localVarRequest.Header.Add(header, value) - } - - 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/samples/client/petstore/go/go-petstore/api_default.go b/samples/client/petstore/go/go-petstore/api_default.go deleted file mode 100644 index cd634d1467d..00000000000 --- a/samples/client/petstore/go/go-petstore/api_default.go +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "io/ioutil" - "net/http" - "net/url" - "strings" - "context" -) - -// Linger please -var ( - _ context.Context -) - -type DefaultApiService service - -/* -DefaultApiService - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body - * @param query - - -*/ -func (a *DefaultApiService) TestBodyWithQueryParams(ctx context.Context, body User, query string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/body-with-query-params" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("query", parameterToString(query, "")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore/api_response.go b/samples/client/petstore/go/go-petstore/api_response.go deleted file mode 100644 index 2e6e99e3e72..00000000000 --- a/samples/client/petstore/go/go-petstore/api_response.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "net/http" -) - -type APIResponse struct { - *http.Response `json:"-"` - Message string `json:"message,omitempty"` - // Operation is the name of the swagger operation. - Operation string `json:"operation,omitempty"` - // RequestURL is the request URL. This value is always available, even if the - // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` - // Method is the HTTP method used for the request. This value is always - // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` - // Payload holds the contents of the response body (which may be nil or empty). - // This is provided here as the raw response.Body() reader will have already - // been drained. - Payload []byte `json:"-"` -} - -func NewAPIResponse(r *http.Response) *APIResponse { - - response := &APIResponse{Response: r} - return response -} - -func NewAPIResponseWithError(errorMessage string) *APIResponse { - - response := &APIResponse{Message: errorMessage} - return response -} diff --git a/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go b/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go deleted file mode 100644 index 183f8096afd..00000000000 --- a/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type ArrayOfArrayOfNumberOnly struct { - ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/array_of_number_only.go b/samples/client/petstore/go/go-petstore/array_of_number_only.go deleted file mode 100644 index 5d91b0f0a84..00000000000 --- a/samples/client/petstore/go/go-petstore/array_of_number_only.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type ArrayOfNumberOnly struct { - ArrayNumber []float32 `json:"ArrayNumber,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/array_test.go b/samples/client/petstore/go/go-petstore/array_test.go deleted file mode 100644 index 574b053f7ff..00000000000 --- a/samples/client/petstore/go/go-petstore/array_test.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type ArrayTest struct { - ArrayOfString []string `json:"array_of_string,omitempty"` - ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty"` - ArrayArrayOfModel [][]ReadOnlyFirst `json:"array_array_of_model,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/capitalization.go b/samples/client/petstore/go/go-petstore/capitalization.go deleted file mode 100644 index d0763abfcfd..00000000000 --- a/samples/client/petstore/go/go-petstore/capitalization.go +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Capitalization struct { - SmallCamel string `json:"smallCamel,omitempty"` - CapitalCamel string `json:"CapitalCamel,omitempty"` - SmallSnake string `json:"small_Snake,omitempty"` - CapitalSnake string `json:"Capital_Snake,omitempty"` - SCAETHFlowPoints string `json:"SCA_ETH_Flow_Points,omitempty"` - // Name of the pet - ATT_NAME string `json:"ATT_NAME,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/cat.go b/samples/client/petstore/go/go-petstore/cat.go deleted file mode 100644 index e9eca0285d1..00000000000 --- a/samples/client/petstore/go/go-petstore/cat.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Cat struct { - ClassName string `json:"className"` - Color string `json:"color,omitempty"` - Declawed bool `json:"declawed,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/category.go b/samples/client/petstore/go/go-petstore/category.go deleted file mode 100644 index 813264818fc..00000000000 --- a/samples/client/petstore/go/go-petstore/category.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Category struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/class_model.go b/samples/client/petstore/go/go-petstore/class_model.go deleted file mode 100644 index c6440c2ed9d..00000000000 --- a/samples/client/petstore/go/go-petstore/class_model.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -// Model for testing model with \"_class\" property -type ClassModel struct { - Class string `json:"_class,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go index fb393f1f9ce..3c9aacc301c 100644 --- a/samples/client/petstore/go/go-petstore/client.go +++ b/samples/client/petstore/go/go-petstore/client.go @@ -10,6 +10,471 @@ package petstore -type Client struct { - Client string `json:"client,omitempty"` +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") +) + +// APIClient manages communication with the Swagger Petstore API v1.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + AnotherFakeApi *AnotherFakeApiService + + FakeApi *FakeApiService + + FakeClassnameTags123Api *FakeClassnameTags123ApiService + + PetApi *PetApiService + + StoreApi *StoreApiService + + UserApi *UserApiService +} + +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.AnotherFakeApi = (*AnotherFakeApiService)(&c.common) + c.FakeApi = (*FakeApiService)(&c.common) + c.FakeClassnameTags123Api = (*FakeClassnameTags123ApiService)(&c.common) + c.PetApi = (*PetApiService)(&c.common) + c.StoreApi = (*StoreApiService)(&c.common) + c.UserApi = (*UserApiService)(&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 "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// 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) { + return true + } + } + return false +} + +// 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 = "|" + case "ssv": + delimiter = " " + case "tsv": + delimiter = "\t" + case "csv": + delimiter = "," + } + + if reflect.TypeOf(obj).Kind() == reflect.Slice { + return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") + } + + return fmt.Sprintf("%v", obj) +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} + +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath(path string) { + c.cfg.BasePath = path +} + +// 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 url.Values, + fileName string, + 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) + } + } + + // Encode the parameters. + url.RawQuery = query.Encode() + + // 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 parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers + } + + // 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) + } + + // 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) + } + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if strings.Contains(contentType, "application/xml") { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } else if strings.Contains(contentType, "application/json") { + if err = json.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + +// 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 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) +} + +// GenericSwaggerError Provides access to the body, error and model on returned errors. +type GenericSwaggerError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericSwaggerError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericSwaggerError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericSwaggerError) Model() interface{} { + return e.model +} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/docs/DefaultApi.md b/samples/client/petstore/go/go-petstore/docs/DefaultApi.md deleted file mode 100644 index 5d4cce1d8be..00000000000 --- a/samples/client/petstore/go/go-petstore/docs/DefaultApi.md +++ /dev/null @@ -1,36 +0,0 @@ -# \DefaultApi - -All URIs are relative to *http://petstore.swagger.io:80/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**TestBodyWithQueryParams**](DefaultApi.md#TestBodyWithQueryParams) | **Put** /fake/body-with-query-params | - - -# **TestBodyWithQueryParams** -> TestBodyWithQueryParams(ctx, body, query) - - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**User**](User.md)| | - **query** | **string**| | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md index 7be602d72a1..ea30cde9a03 100644 --- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md +++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md @@ -237,16 +237,16 @@ Name | Type | Description | Notes - **integer** | **optional.**| None | - **int32_** | **optional.**| None | - **int64_** | **optional.**| None | - **float** | **optional.**| None | - **string_** | **optional.**| None | - **binary** | **optional.**| None | - **date** | **optional.**| None | - **dateTime** | **optional.**| None | - **password** | **optional.**| None | - **callback** | **optional.**| None | + **integer** | **optional.Int32**| None | + **int32_** | **optional.Int32**| None | + **int64_** | **optional.Int64**| None | + **float** | **optional.Float32**| None | + **string_** | **optional.String**| None | + **binary** | **optional.String**| None | + **date** | **optional.String**| None | + **dateTime** | **optional.Time**| None | + **password** | **optional.String**| None | + **callback** | **optional.String**| None | ### Return type @@ -282,13 +282,13 @@ Optional parameters are passed through a pointer to a TestEnumParametersOpts str Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **enumFormStringArray** | [**optional.Interface of []string**](string.md)| Form parameter enum test (string array) | - **enumFormString** | **optional.**| Form parameter enum test (string) | [default to -efg] + **enumFormString** | **optional.String**| Form parameter enum test (string) | [default to -efg] **enumHeaderStringArray** | [**optional.Interface of []string**](string.md)| Header parameter enum test (string array) | - **enumHeaderString** | **optional.**| Header parameter enum test (string) | [default to -efg] + **enumHeaderString** | **optional.String**| Header parameter enum test (string) | [default to -efg] **enumQueryStringArray** | [**optional.Interface of []string**](string.md)| Query parameter enum test (string array) | - **enumQueryString** | **optional.**| Query parameter enum test (string) | [default to -efg] - **enumQueryInteger** | **optional.**| Query parameter enum test (double) | - **enumQueryDouble** | **optional.**| Query parameter enum test (double) | + **enumQueryString** | **optional.String**| Query parameter enum test (string) | [default to -efg] + **enumQueryInteger** | **optional.Int32**| Query parameter enum test (double) | + **enumQueryDouble** | **optional.Float64**| Query parameter enum test (double) | ### Return type diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md index 75268c7acfa..3498e990c4f 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md @@ -62,7 +62,7 @@ Optional parameters are passed through a pointer to a DeletePetOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **apiKey** | **optional.**| | + **apiKey** | **optional.String**| | ### Return type @@ -211,8 +211,8 @@ Optional parameters are passed through a pointer to a UpdatePetWithFormOpts stru Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **name** | **optional.**| Updated name of the pet | - **status** | **optional.**| Updated status of the pet | + **name** | **optional.String**| Updated name of the pet | + **status** | **optional.String**| Updated status of the pet | ### Return type @@ -249,7 +249,7 @@ Optional parameters are passed through a pointer to a UploadFileOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **additionalMetadata** | **optional.**| Additional data to pass to server | + **additionalMetadata** | **optional.String**| Additional data to pass to server | **file** | **optional.Interface of *os.File**| file to upload | ### Return type diff --git a/samples/client/petstore/go/go-petstore/dog.go b/samples/client/petstore/go/go-petstore/dog.go deleted file mode 100644 index a3a923e4fc5..00000000000 --- a/samples/client/petstore/go/go-petstore/dog.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Dog struct { - ClassName string `json:"className"` - Color string `json:"color,omitempty"` - Breed string `json:"breed,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/enum_arrays.go b/samples/client/petstore/go/go-petstore/enum_arrays.go deleted file mode 100644 index 7442b677e86..00000000000 --- a/samples/client/petstore/go/go-petstore/enum_arrays.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type EnumArrays struct { - JustSymbol string `json:"just_symbol,omitempty"` - ArrayEnum []string `json:"array_enum,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/enum_class.go b/samples/client/petstore/go/go-petstore/enum_class.go deleted file mode 100644 index ca1f2daae70..00000000000 --- a/samples/client/petstore/go/go-petstore/enum_class.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type EnumClass string - -// List of EnumClass -const ( - ABC_EnumClass EnumClass = "_abc" - EFG_EnumClass EnumClass = "-efg" - XYZ_EnumClass EnumClass = "(xyz)" -) diff --git a/samples/client/petstore/go/go-petstore/enum_test.go b/samples/client/petstore/go/go-petstore/enum_test.go deleted file mode 100644 index f6d32a52339..00000000000 --- a/samples/client/petstore/go/go-petstore/enum_test.go +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type EnumTest struct { - EnumString string `json:"enum_string,omitempty"` - EnumStringRequired string `json:"enum_string_required"` - EnumInteger int32 `json:"enum_integer,omitempty"` - EnumNumber float64 `json:"enum_number,omitempty"` - OuterEnum *OuterEnum `json:"outerEnum,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/fake_api.go b/samples/client/petstore/go/go-petstore/fake_api.go deleted file mode 100644 index 5c3ef5fdf4c..00000000000 --- a/samples/client/petstore/go/go-petstore/fake_api.go +++ /dev/null @@ -1,1006 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "time" - "encoding/json" -) - -// Linger please -var ( - _ context.Context -) - -type FakeApiService service - -/* -FakeApiService -Test serialization of outer boolean types - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *FakeOuterBooleanSerializeOpts - Optional Parameters: - * @param "Body" (optional.Interface of OuterBoolean) - Input boolean as post body - -@return OuterBoolean -*/ - -type FakeOuterBooleanSerializeOpts struct { - Body optional.Interface -} - -func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals *FakeOuterBooleanSerializeOpts) (OuterBoolean, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue OuterBoolean - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/outer/boolean" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - if localVarOptionals != nil && localVarOptionals.Body.IsSet() { - - localVarOptionalBody, localVarOptionalBodyok := localVarOptionals.Body.Value().(OuterBoolean) - if !localVarOptionalBodyok { - return localVarReturnValue, nil, reportError("body should be OuterBoolean") - } - localVarPostBody = &localVarOptionalBody - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v OuterBoolean - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -FakeApiService -Test serialization of object with outer number type - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *FakeOuterCompositeSerializeOpts - Optional Parameters: - * @param "Body" (optional.Interface of OuterComposite) - Input composite as post body - -@return OuterComposite -*/ - -type FakeOuterCompositeSerializeOpts struct { - Body optional.Interface -} - -func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals *FakeOuterCompositeSerializeOpts) (OuterComposite, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue OuterComposite - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/outer/composite" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - if localVarOptionals != nil && localVarOptionals.Body.IsSet() { - - localVarOptionalBody, localVarOptionalBodyok := localVarOptionals.Body.Value().(OuterComposite) - if !localVarOptionalBodyok { - return localVarReturnValue, nil, reportError("body should be OuterComposite") - } - localVarPostBody = &localVarOptionalBody - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v OuterComposite - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -FakeApiService -Test serialization of outer number types - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *FakeOuterNumberSerializeOpts - Optional Parameters: - * @param "Body" (optional.Interface of OuterNumber) - Input number as post body - -@return OuterNumber -*/ - -type FakeOuterNumberSerializeOpts struct { - Body optional.Interface -} - -func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals *FakeOuterNumberSerializeOpts) (OuterNumber, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue OuterNumber - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/outer/number" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - if localVarOptionals != nil && localVarOptionals.Body.IsSet() { - - localVarOptionalBody, localVarOptionalBodyok := localVarOptionals.Body.Value().(OuterNumber) - if !localVarOptionalBodyok { - return localVarReturnValue, nil, reportError("body should be OuterNumber") - } - localVarPostBody = &localVarOptionalBody - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v OuterNumber - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -FakeApiService -Test serialization of outer string types - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *FakeOuterStringSerializeOpts - Optional Parameters: - * @param "Body" (optional.Interface of OuterString) - Input string as post body - -@return OuterString -*/ - -type FakeOuterStringSerializeOpts struct { - Body optional.Interface -} - -func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals *FakeOuterStringSerializeOpts) (OuterString, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue OuterString - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/outer/string" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - if localVarOptionals != nil && localVarOptionals.Body.IsSet() { - - localVarOptionalBody, localVarOptionalBodyok := localVarOptionals.Body.Value().(OuterString) - if !localVarOptionalBodyok { - return localVarReturnValue, nil, reportError("body should be OuterString") - } - localVarPostBody = &localVarOptionalBody - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v OuterString - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -FakeApiService - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body - * @param query - - -*/ -func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, body User, query string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/body-with-query-params" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("query", parameterToString(query, "")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -FakeApiService To test \"client\" model -To test \"client\" model - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body client model - -@return Client -*/ -func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Client, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Patch") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Client - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v Client - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 -Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param number None - * @param double None - * @param patternWithoutDelimiter None - * @param byte_ None - * @param optional nil or *TestEndpointParametersOpts - Optional Parameters: - * @param "Integer" (optional.) - None - * @param "Int32_" (optional.) - None - * @param "Int64_" (optional.) - None - * @param "Float" (optional.) - None - * @param "String_" (optional.) - None - * @param "Binary" (optional.) - None - * @param "Date" (optional.) - None - * @param "DateTime" (optional.) - None - * @param "Password" (optional.) - None - * @param "Callback" (optional.) - None - - -*/ - -type TestEndpointParametersOpts struct { - Integer optional. - Int32_ optional. - Int64_ optional. - Float optional. - String_ optional. - Binary optional. - Date optional. - DateTime optional. - Password optional. - Callback optional. -} - -func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals *TestEndpointParametersOpts) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if number < 32.1 { - return nil, reportError("number must be greater than 32.1") - } - if number > 543.2 { - return nil, reportError("number must be less than 543.2") - } - if double < 67.8 { - return nil, reportError("double must be greater than 67.8") - } - if double > 123.4 { - return nil, reportError("double must be less than 123.4") - } - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - if localVarOptionals != nil && localVarOptionals.Integer.IsSet() { - localVarFormParams.Add("integer", parameterToString(localVarOptionals.Integer.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.Int32_.IsSet() { - localVarFormParams.Add("int32", parameterToString(localVarOptionals.Int32_.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.Int64_.IsSet() { - localVarFormParams.Add("int64", parameterToString(localVarOptionals.Int64_.Value(), "")) - } - localVarFormParams.Add("number", parameterToString(number, "")) - if localVarOptionals != nil && localVarOptionals.Float.IsSet() { - localVarFormParams.Add("float", parameterToString(localVarOptionals.Float.Value(), "")) - } - localVarFormParams.Add("double", parameterToString(double, "")) - if localVarOptionals != nil && localVarOptionals.String_.IsSet() { - localVarFormParams.Add("string", parameterToString(localVarOptionals.String_.Value(), "")) - } - localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, "")) - localVarFormParams.Add("byte", parameterToString(byte_, "")) - if localVarOptionals != nil && localVarOptionals.Binary.IsSet() { - localVarFormParams.Add("binary", parameterToString(localVarOptionals.Binary.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.Date.IsSet() { - localVarFormParams.Add("date", parameterToString(localVarOptionals.Date.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.DateTime.IsSet() { - localVarFormParams.Add("dateTime", parameterToString(localVarOptionals.DateTime.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.Password.IsSet() { - localVarFormParams.Add("password", parameterToString(localVarOptionals.Password.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.Callback.IsSet() { - localVarFormParams.Add("callback", parameterToString(localVarOptionals.Callback.Value(), "")) - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -FakeApiService To test enum parameters -To test enum parameters - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *TestEnumParametersOpts - Optional Parameters: - * @param "EnumFormStringArray" (optional.Interface of []string) - Form parameter enum test (string array) - * @param "EnumFormString" (optional.) - Form parameter enum test (string) - * @param "EnumHeaderStringArray" (optional.Interface of []string) - Header parameter enum test (string array) - * @param "EnumHeaderString" (optional.) - Header parameter enum test (string) - * @param "EnumQueryStringArray" (optional.Interface of []string) - Query parameter enum test (string array) - * @param "EnumQueryString" (optional.) - Query parameter enum test (string) - * @param "EnumQueryInteger" (optional.) - Query parameter enum test (double) - * @param "EnumQueryDouble" (optional.) - Query parameter enum test (double) - - -*/ - -type TestEnumParametersOpts struct { - EnumFormStringArray optional.Interface - EnumFormString optional. - EnumHeaderStringArray optional.Interface - EnumHeaderString optional. - EnumQueryStringArray optional.Interface - EnumQueryString optional. - EnumQueryInteger optional. - EnumQueryDouble optional. -} - -func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals *TestEnumParametersOpts) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if localVarOptionals != nil && localVarOptionals.EnumQueryStringArray.IsSet() { - localVarQueryParams.Add("enum_query_string_array", parameterToString(localVarOptionals.EnumQueryStringArray.Value(), "csv")) - } - if localVarOptionals != nil && localVarOptionals.EnumQueryString.IsSet() { - localVarQueryParams.Add("enum_query_string", parameterToString(localVarOptionals.EnumQueryString.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.EnumQueryInteger.IsSet() { - localVarQueryParams.Add("enum_query_integer", parameterToString(localVarOptionals.EnumQueryInteger.Value(), "")) - } - // to determine the Content-Type header - localVarHttpContentTypes := []string{"*/*"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"*/*"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - if localVarOptionals != nil && localVarOptionals.EnumHeaderStringArray.IsSet() { - localVarHeaderParams["enum_header_string_array"] = parameterToString(localVarOptionals.EnumHeaderStringArray.Value(), "csv") - } - if localVarOptionals != nil && localVarOptionals.EnumHeaderString.IsSet() { - localVarHeaderParams["enum_header_string"] = parameterToString(localVarOptionals.EnumHeaderString.Value(), "") - } - if localVarOptionals != nil && localVarOptionals.EnumFormStringArray.IsSet() { - localVarFormParams.Add("enum_form_string_array", parameterToString(localVarOptionals.EnumFormStringArray.Value(), "csv")) - } - if localVarOptionals != nil && localVarOptionals.EnumFormString.IsSet() { - localVarFormParams.Add("enum_form_string", parameterToString(localVarOptionals.EnumFormString.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.EnumQueryDouble.IsSet() { - localVarFormParams.Add("enum_query_double", parameterToString(localVarOptionals.EnumQueryDouble.Value(), "")) - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -FakeApiService test inline additionalProperties - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param param request body - - -*/ -func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, param interface{}) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/inline-additionalProperties" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = ¶m - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -FakeApiService test json serialization of form data - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param param field1 - * @param param2 field2 - - -*/ -func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, param2 string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake/jsonFormData" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - localVarFormParams.Add("param", parameterToString(param, "")) - localVarFormParams.Add("param2", parameterToString(param2, "")) - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go b/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go deleted file mode 100644 index 3b127169bd3..00000000000 --- a/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "encoding/json" -) - -// Linger please -var ( - _ context.Context -) - -type FakeClassnameTags123ApiService service - -/* -FakeClassnameTags123ApiService To test class name in snake case -To test class name in snake case - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body client model - -@return Client -*/ -func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body Client) (Client, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Patch") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Client - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/fake_classname_test" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &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 - } - - localVarQueryParams.Add("api_key_query", key) - } - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v Client - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore/format_test.go b/samples/client/petstore/go/go-petstore/format_test.go deleted file mode 100644 index 920e4bc4749..00000000000 --- a/samples/client/petstore/go/go-petstore/format_test.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "time" -) - -type FormatTest struct { - Integer int32 `json:"integer,omitempty"` - Int32_ int32 `json:"int32,omitempty"` - Int64_ int64 `json:"int64,omitempty"` - Number float32 `json:"number"` - Float float32 `json:"float,omitempty"` - Double float64 `json:"double,omitempty"` - String_ string `json:"string,omitempty"` - Byte_ string `json:"byte"` - Binary string `json:"binary,omitempty"` - Date string `json:"date"` - DateTime time.Time `json:"dateTime,omitempty"` - Uuid string `json:"uuid,omitempty"` - Password string `json:"password"` -} diff --git a/samples/client/petstore/go/go-petstore/has_only_read_only.go b/samples/client/petstore/go/go-petstore/has_only_read_only.go deleted file mode 100644 index 350ba612d76..00000000000 --- a/samples/client/petstore/go/go-petstore/has_only_read_only.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type HasOnlyReadOnly struct { - Bar string `json:"bar,omitempty"` - Foo string `json:"foo,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/list.go b/samples/client/petstore/go/go-petstore/list.go deleted file mode 100644 index 44d4cb982ea..00000000000 --- a/samples/client/petstore/go/go-petstore/list.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type List struct { - Var123List string `json:"123-list,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/map_test.go b/samples/client/petstore/go/go-petstore/map_test.go deleted file mode 100644 index 02ef102c057..00000000000 --- a/samples/client/petstore/go/go-petstore/map_test.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type MapTest struct { - MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty"` - MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go deleted file mode 100644 index 0d4254b7f07..00000000000 --- a/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "time" -) - -type MixedPropertiesAndAdditionalPropertiesClass struct { - Uuid string `json:"uuid,omitempty"` - DateTime time.Time `json:"dateTime,omitempty"` - Map_ map[string]Animal `json:"map,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/model_enum_class.go b/samples/client/petstore/go/go-petstore/model_enum_class.go index 4950a03e747..ca1f2daae70 100644 --- a/samples/client/petstore/go/go-petstore/model_enum_class.go +++ b/samples/client/petstore/go/go-petstore/model_enum_class.go @@ -14,7 +14,7 @@ type EnumClass string // List of EnumClass const ( - ABC EnumClass = "_abc" - EFG EnumClass = "-efg" - XYZ EnumClass = "(xyz)" + ABC_EnumClass EnumClass = "_abc" + EFG_EnumClass EnumClass = "-efg" + XYZ_EnumClass EnumClass = "(xyz)" ) diff --git a/samples/client/petstore/go/go-petstore/model_outer_enum.go b/samples/client/petstore/go/go-petstore/model_outer_enum.go index 0e724d17c5c..31ce691a70a 100644 --- a/samples/client/petstore/go/go-petstore/model_outer_enum.go +++ b/samples/client/petstore/go/go-petstore/model_outer_enum.go @@ -14,7 +14,7 @@ type OuterEnum string // List of OuterEnum const ( - PLACED OuterEnum = "placed" - APPROVED OuterEnum = "approved" - DELIVERED OuterEnum = "delivered" + PLACED_OuterEnum OuterEnum = "placed" + APPROVED_OuterEnum OuterEnum = "approved" + DELIVERED_OuterEnum OuterEnum = "delivered" ) diff --git a/samples/client/petstore/go/go-petstore/name.go b/samples/client/petstore/go/go-petstore/name.go deleted file mode 100644 index c2a5b7d9aa4..00000000000 --- a/samples/client/petstore/go/go-petstore/name.go +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -// Model for testing model name same as property name -type Name struct { - Name int32 `json:"name"` - SnakeCase int32 `json:"snake_case,omitempty"` - Property string `json:"property,omitempty"` - Var123Number int32 `json:"123Number,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/number_only.go b/samples/client/petstore/go/go-petstore/number_only.go deleted file mode 100644 index 631de12e68a..00000000000 --- a/samples/client/petstore/go/go-petstore/number_only.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type NumberOnly struct { - JustNumber float32 `json:"JustNumber,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/order.go b/samples/client/petstore/go/go-petstore/order.go deleted file mode 100644 index a659c4eb637..00000000000 --- a/samples/client/petstore/go/go-petstore/order.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "time" -) - -type Order struct { - Id int64 `json:"id,omitempty"` - PetId int64 `json:"petId,omitempty"` - Quantity int32 `json:"quantity,omitempty"` - ShipDate time.Time `json:"shipDate,omitempty"` - // Order Status - Status string `json:"status,omitempty"` - Complete bool `json:"complete,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/outer_boolean.go b/samples/client/petstore/go/go-petstore/outer_boolean.go deleted file mode 100644 index dc9ceb0c67e..00000000000 --- a/samples/client/petstore/go/go-petstore/outer_boolean.go +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type OuterBoolean struct { -} diff --git a/samples/client/petstore/go/go-petstore/outer_composite.go b/samples/client/petstore/go/go-petstore/outer_composite.go deleted file mode 100644 index 2db01931558..00000000000 --- a/samples/client/petstore/go/go-petstore/outer_composite.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type OuterComposite struct { - MyNumber *OuterNumber `json:"my_number,omitempty"` - MyString *OuterString `json:"my_string,omitempty"` - MyBoolean *OuterBoolean `json:"my_boolean,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/outer_enum.go b/samples/client/petstore/go/go-petstore/outer_enum.go deleted file mode 100644 index 31ce691a70a..00000000000 --- a/samples/client/petstore/go/go-petstore/outer_enum.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type OuterEnum string - -// List of OuterEnum -const ( - PLACED_OuterEnum OuterEnum = "placed" - APPROVED_OuterEnum OuterEnum = "approved" - DELIVERED_OuterEnum OuterEnum = "delivered" -) diff --git a/samples/client/petstore/go/go-petstore/outer_number.go b/samples/client/petstore/go/go-petstore/outer_number.go deleted file mode 100644 index 75aad986c34..00000000000 --- a/samples/client/petstore/go/go-petstore/outer_number.go +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type OuterNumber struct { -} diff --git a/samples/client/petstore/go/go-petstore/outer_string.go b/samples/client/petstore/go/go-petstore/outer_string.go deleted file mode 100644 index f2a440337bd..00000000000 --- a/samples/client/petstore/go/go-petstore/outer_string.go +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type OuterString struct { -} diff --git a/samples/client/petstore/go/go-petstore/pet.go b/samples/client/petstore/go/go-petstore/pet.go deleted file mode 100644 index 01687924d91..00000000000 --- a/samples/client/petstore/go/go-petstore/pet.go +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Pet struct { - Id int64 `json:"id,omitempty"` - Category *Category `json:"category,omitempty"` - Name string `json:"name"` - PhotoUrls []string `json:"photoUrls"` - Tags []Tag `json:"tags,omitempty"` - // pet status in the store - Status string `json:"status,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go deleted file mode 100644 index 24cb39f0623..00000000000 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ /dev/null @@ -1,735 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "os" - "encoding/json" - "fmt" -) - -// Linger please -var ( - _ context.Context -) - -type PetApiService service - -/* -PetApiService Add a new pet to the store - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Pet object that needs to be added to the store - - -*/ -func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json", "application/xml"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -PetApiService Deletes a pet - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param petId Pet id to delete - * @param optional nil or *DeletePetOpts - Optional Parameters: - * @param "ApiKey" (optional.) - - - -*/ - -type DeletePetOpts struct { - ApiKey optional. -} - -func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals *DeletePetOpts) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet/{petId}" - localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - if localVarOptionals != nil && localVarOptionals.ApiKey.IsSet() { - localVarHeaderParams["api_key"] = parameterToString(localVarOptionals.ApiKey.Value(), "") - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -PetApiService Finds Pets by status -Multiple status values can be provided with comma separated strings - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param status Status values that need to be considered for filter - -@return []Pet -*/ -func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ([]Pet, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue []Pet - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet/findByStatus" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("status", parameterToString(status, "csv")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v []Pet - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -PetApiService Finds Pets by tags -Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param tags Tags to filter by - -@return []Pet -*/ -func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pet, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue []Pet - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet/findByTags" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("tags", parameterToString(tags, "csv")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v []Pet - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -PetApiService Find pet by ID -Returns a single pet - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param petId ID of pet to return - -@return Pet -*/ -func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Pet - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet/{petId}" - localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - 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["api_key"] = key - - } - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v Pet - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -PetApiService Update an existing pet - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Pet object that needs to be added to the store - - -*/ -func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json", "application/xml"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -PetApiService Updates a pet in the store with form data - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param petId ID of pet that needs to be updated - * @param optional nil or *UpdatePetWithFormOpts - Optional Parameters: - * @param "Name" (optional.) - Updated name of the pet - * @param "Status" (optional.) - Updated status of the pet - - -*/ - -type UpdatePetWithFormOpts struct { - Name optional. - Status optional. -} - -func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals *UpdatePetWithFormOpts) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet/{petId}" - localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - if localVarOptionals != nil && localVarOptionals.Name.IsSet() { - localVarFormParams.Add("name", parameterToString(localVarOptionals.Name.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.Status.IsSet() { - localVarFormParams.Add("status", parameterToString(localVarOptionals.Status.Value(), "")) - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -PetApiService uploads an image - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param petId ID of pet to update - * @param optional nil or *UploadFileOpts - Optional Parameters: - * @param "AdditionalMetadata" (optional.) - Additional data to pass to server - * @param "File" (optional.Interface of *os.File) - file to upload - -@return ModelApiResponse -*/ - -type UploadFileOpts struct { - AdditionalMetadata optional. - File optional.Interface -} - -func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals *UploadFileOpts) (ModelApiResponse, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue ModelApiResponse - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/pet/{petId}/uploadImage" - localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"multipart/form-data"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - if localVarOptionals != nil && localVarOptionals.AdditionalMetadata.IsSet() { - localVarFormParams.Add("additionalMetadata", parameterToString(localVarOptionals.AdditionalMetadata.Value(), "")) - } - var localVarFile *os.File - if localVarOptionals != nil && localVarOptionals.File.IsSet() { - localVarFileOk := false - localVarFile, localVarFileOk = localVarOptionals.File.Value().(*os.File) - if !localVarFileOk { - return localVarReturnValue, nil, reportError("file should be *os.File") - } - } - if localVarFile != nil { - fbs, _ := ioutil.ReadAll(localVarFile) - localVarFileBytes = fbs - localVarFileName = localVarFile.Name() - localVarFile.Close() - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v ModelApiResponse - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore/read_only_first.go b/samples/client/petstore/go/go-petstore/read_only_first.go deleted file mode 100644 index becf588c124..00000000000 --- a/samples/client/petstore/go/go-petstore/read_only_first.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type ReadOnlyFirst struct { - Bar string `json:"bar,omitempty"` - Baz string `json:"baz,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/special_model_name.go b/samples/client/petstore/go/go-petstore/special_model_name.go deleted file mode 100644 index 252c3779f09..00000000000 --- a/samples/client/petstore/go/go-petstore/special_model_name.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type SpecialModelName struct { - SpecialPropertyName int64 `json:"$special[property.name],omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go deleted file mode 100644 index 79d29164c6e..00000000000 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "encoding/json" - "fmt" -) - -// Linger please -var ( - _ context.Context -) - -type StoreApiService service - -/* -StoreApiService Delete purchase order by ID -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param orderId ID of the order that needs to be deleted - - -*/ -func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/store/order/{order_id}" - localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", fmt.Sprintf("%v", orderId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -StoreApiService Returns pet inventories by status -Returns a map of status codes to quantities - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - -@return map[string]int32 -*/ -func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue map[string]int32 - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/store/inventory" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - 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["api_key"] = key - - } - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v map[string]int32 - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -StoreApiService Find purchase order by ID -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param orderId ID of pet that needs to be fetched - -@return Order -*/ -func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Order, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Order - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/store/order/{order_id}" - localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", fmt.Sprintf("%v", orderId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if orderId < 1 { - return localVarReturnValue, nil, reportError("orderId must be greater than 1") - } - if orderId > 5 { - return localVarReturnValue, nil, reportError("orderId must be less than 5") - } - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v Order - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -StoreApiService Place an order for a pet - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body order placed for purchasing the pet - -@return Order -*/ -func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Order - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/store/order" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v Order - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} diff --git a/samples/client/petstore/go/go-petstore/tag.go b/samples/client/petstore/go/go-petstore/tag.go deleted file mode 100644 index 0c51bb7d881..00000000000 --- a/samples/client/petstore/go/go-petstore/tag.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type Tag struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/user.go b/samples/client/petstore/go/go-petstore/user.go deleted file mode 100644 index 3bdf7cc4464..00000000000 --- a/samples/client/petstore/go/go-petstore/user.go +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -type User struct { - Id int64 `json:"id,omitempty"` - Username string `json:"username,omitempty"` - FirstName string `json:"firstName,omitempty"` - LastName string `json:"lastName,omitempty"` - Email string `json:"email,omitempty"` - Password string `json:"password,omitempty"` - Phone string `json:"phone,omitempty"` - // User Status - UserStatus int32 `json:"userStatus,omitempty"` -} diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go deleted file mode 100644 index 2df2d709e5e..00000000000 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ /dev/null @@ -1,638 +0,0 @@ -/* - * Swagger Petstore - * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - * - * API version: 1.0.0 - * Contact: apiteam@swagger.io - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ - -package petstore - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "encoding/json" - "fmt" -) - -// Linger please -var ( - _ context.Context -) - -type UserApiService service - -/* -UserApiService Create user -This can only be done by the logged in user. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Created user object - - -*/ -func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -UserApiService Creates list of users with given input array - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body List of user object - - -*/ -func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/createWithArray" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -UserApiService Creates list of users with given input array - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body List of user object - - -*/ -func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/createWithList" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -UserApiService Delete user -This can only be done by the logged in user. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username The name that needs to be deleted - - -*/ -func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/{username}" - localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -UserApiService Get user by user name - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username The name that needs to be fetched. Use user1 for testing. - -@return User -*/ -func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue User - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/{username}" - localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v User - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -UserApiService Logs user into the system - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username The user name for login - * @param password The password for login in clear text - -@return string -*/ -func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue string - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/login" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("username", parameterToString(username, "")) - localVarQueryParams.Add("password", parameterToString(password, "")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - if localVarHttpResponse.StatusCode == 200 { - var v string - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} - -/* -UserApiService Logs out current logged in user session - - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - - -*/ -func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/logout" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} - -/* -UserApiService Updated user -This can only be done by the logged in user. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username name that need to be deleted - * @param body Updated user object - - -*/ -func (a *UserApiService) UpdateUser(ctx context.Context, username string, body User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/{username}" - localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -}