diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 4d6b97202b3..e7f3c36c6a0 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -21,7 +21,7 @@ var ( type {{classname}}Service service {{#operation}} -/* +/* {{{classname}}}Service{{#summary}} {{.}}{{/summary}}{{#notes}} {{notes}}{{/notes}} * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -235,9 +235,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} 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 {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err - } + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err } {{/returnType}} @@ -263,4 +261,4 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil } -{{/operation}}{{/operations}} \ No newline at end of file +{{/operation}}{{/operations}} diff --git a/samples/client/petstore-security-test/go/.swagger-codegen/VERSION b/samples/client/petstore-security-test/go/.swagger-codegen/VERSION index a6254504e40..0443c4ad098 100644 --- a/samples/client/petstore-security-test/go/.swagger-codegen/VERSION +++ b/samples/client/petstore-security-test/go/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 \ No newline at end of file +2.4.16-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/go/api/swagger.yaml b/samples/client/petstore-security-test/go/api/swagger.yaml index 81d2ac1b8bb..7f3a6a8b40f 100644 --- a/samples/client/petstore-security-test/go/api/swagger.yaml +++ b/samples/client/petstore-security-test/go/api/swagger.yaml @@ -41,8 +41,9 @@ paths: required: false type: "string" x-exportParamName: "TestCodeInjectEndRnNR" + x-optionalDataType: "String" responses: - 400: + "400": description: "To test code injection */ ' \" =end -- \\r\\n \\n \\r" securityDefinitions: petstore_auth: @@ -63,10 +64,9 @@ definitions: type: "integer" format: "int32" description: "property description */ ' \" =end -- \\r\\n \\n \\r" - description: "Model for testing reserved words */ ' \" =end -- \\r\\n \\n \\r" xml: name: "Return" - + description: "Model for testing reserved words */ ' \" =end -- \\r\\n \\n \\r" externalDocs: description: "Find out more about Swagger */ ' \" =end -- \\r\\n \\n \\r" url: "http://swagger.io" diff --git a/samples/client/petstore-security-test/go/api_fake.go b/samples/client/petstore-security-test/go/api_fake.go index a19200a1fac..a4c4305eac1 100644 --- a/samples/client/petstore-security-test/go/api_fake.go +++ b/samples/client/petstore-security-test/go/api_fake.go @@ -1,3 +1,4 @@ + /* * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r * @@ -26,20 +27,20 @@ var ( type FakeApiService service -/* +/* FakeApiService To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *TestCodeInjectEndRnNROpts - Optional Parameters: + * @param optional nil or *FakeApiTestCodeInjectEndRnNROpts - Optional Parameters: * @param "TestCodeInjectEndRnNR" (optional.String) - To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ -type TestCodeInjectEndRnNROpts struct { +type FakeApiTestCodeInjectEndRnNROpts struct { TestCodeInjectEndRnNR optional.String } -func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals *TestCodeInjectEndRnNROpts) (*http.Response, error) { +func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals *FakeApiTestCodeInjectEndRnNROpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} @@ -103,3 +104,4 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti return localVarHttpResponse, nil } + diff --git a/samples/client/petstore-security-test/go/client.go b/samples/client/petstore-security-test/go/client.go index ceacaa4445a..938472e6f59 100644 --- a/samples/client/petstore-security-test/go/client.go +++ b/samples/client/petstore-security-test/go/client.go @@ -34,8 +34,8 @@ import ( ) var ( - jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") + jsonCheck = regexp.MustCompile("(?i:(?:application|text)/json)") + xmlCheck = regexp.MustCompile("(?i:(?:application|text)/xml)") ) // APIClient manages communication with the Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r API v1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r diff --git a/samples/client/petstore-security-test/go/docs/FakeApi.md b/samples/client/petstore-security-test/go/docs/FakeApi.md index 1d7dea697cc..6444f27fde8 100644 --- a/samples/client/petstore-security-test/go/docs/FakeApi.md +++ b/samples/client/petstore-security-test/go/docs/FakeApi.md @@ -16,14 +16,14 @@ To test code injection *_/ ' \" =end -- \\r\\n \\n \\r Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **optional** | ***TestCodeInjectEndRnNROpts** | optional parameters | nil if no parameters + **optional** | ***FakeApiTestCodeInjectEndRnNROpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a pointer to a TestCodeInjectEndRnNROpts struct +Optional parameters are passed through a pointer to a FakeApiTestCodeInjectEndRnNROpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **testCodeInjectEndRnNR** | **optional.**| To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | + **testCodeInjectEndRnNR** | **optional.String**| To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | ### Return type 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 6cecc1a68f3..0443c4ad098 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.6-SNAPSHOT \ No newline at end of file +2.4.16-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore-withXml/README.md b/samples/client/petstore/go/go-petstore-withXml/README.md index d3d111dda49..dc14850d4b0 100644 --- a/samples/client/petstore/go/go-petstore-withXml/README.md +++ b/samples/client/petstore/go/go-petstore-withXml/README.md @@ -64,9 +64,11 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [Capitalization](docs/Capitalization.md) + - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) + - [Dog](docs/Dog.md) - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) @@ -91,8 +93,6 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [Tag](docs/Tag.md) - [User](docs/User.md) - - [Cat](docs/Cat.md) - - [Dog](docs/Dog.md) ## Documentation For Authorization 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 d8749671bcb..35a55274005 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml +++ b/samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml @@ -52,7 +52,7 @@ paths: $ref: "#/definitions/Pet" x-exportParamName: "Body" responses: - 405: + "405": description: "Invalid input" security: - petstore_auth: @@ -79,11 +79,11 @@ paths: $ref: "#/definitions/Pet" x-exportParamName: "Body" responses: - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Pet not found" - 405: + "405": description: "Validation exception" security: - petstore_auth: @@ -115,13 +115,13 @@ paths: collectionFormat: "csv" x-exportParamName: "Status" responses: - 200: + "200": description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" - 400: + "400": description: "Invalid status value" security: - petstore_auth: @@ -149,13 +149,13 @@ paths: collectionFormat: "csv" x-exportParamName: "Tags" responses: - 200: + "200": description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" - 400: + "400": description: "Invalid tag value" security: - petstore_auth: @@ -181,13 +181,13 @@ paths: format: "int64" x-exportParamName: "PetId" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Pet" - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Pet not found" security: - api_key: [] @@ -225,7 +225,7 @@ paths: x-exportParamName: "Status" x-optionalDataType: "String" responses: - 405: + "405": description: "Invalid input" security: - petstore_auth: @@ -255,7 +255,7 @@ paths: format: "int64" x-exportParamName: "PetId" responses: - 400: + "400": description: "Invalid pet value" security: - petstore_auth: @@ -294,7 +294,7 @@ paths: type: "file" x-exportParamName: "File" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/ApiResponse" @@ -313,7 +313,7 @@ paths: - "application/json" parameters: [] responses: - 200: + "200": description: "successful operation" schema: type: "object" @@ -341,11 +341,11 @@ paths: $ref: "#/definitions/Order" x-exportParamName: "Body" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Order" - 400: + "400": description: "Invalid Order" /store/order/{order_id}: get: @@ -369,13 +369,13 @@ paths: format: "int64" x-exportParamName: "OrderId" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Order" - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Order not found" delete: tags: @@ -395,9 +395,9 @@ paths: type: "string" x-exportParamName: "OrderId" responses: - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Order not found" /user: post: @@ -490,7 +490,7 @@ paths: type: "string" x-exportParamName: "Password" responses: - 200: + "200": description: "successful operation" headers: X-Rate-Limit: @@ -503,7 +503,7 @@ paths: description: "date in UTC when token expires" schema: type: "string" - 400: + "400": description: "Invalid username/password supplied" /user/logout: get: @@ -537,13 +537,13 @@ paths: type: "string" x-exportParamName: "Username" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/User" - 400: + "400": description: "Invalid username supplied" - 404: + "404": description: "User not found" put: tags: @@ -569,9 +569,9 @@ paths: $ref: "#/definitions/User" x-exportParamName: "Body" responses: - 400: + "400": description: "Invalid user supplied" - 404: + "404": description: "User not found" delete: tags: @@ -590,9 +590,9 @@ paths: type: "string" x-exportParamName: "Username" responses: - 400: + "400": description: "Invalid username supplied" - 404: + "404": description: "User not found" /fake_classname_test: patch: @@ -614,7 +614,7 @@ paths: $ref: "#/definitions/Client" x-exportParamName: "Body" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Client" @@ -727,9 +727,9 @@ paths: x-exportParamName: "EnumQueryDouble" x-optionalDataType: "Float64" responses: - 400: + "400": description: "Invalid request" - 404: + "404": description: "Not found" post: tags: @@ -863,9 +863,9 @@ paths: x-exportParamName: "Callback" x-optionalDataType: "String" responses: - 400: + "400": description: "Invalid username supplied" - 404: + "404": description: "User not found" security: - http_basic_test: [] @@ -888,7 +888,7 @@ paths: $ref: "#/definitions/Client" x-exportParamName: "Body" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Client" @@ -907,7 +907,7 @@ paths: $ref: "#/definitions/OuterNumber" x-exportParamName: "Body" responses: - 200: + "200": description: "Output number" schema: $ref: "#/definitions/OuterNumber" @@ -926,7 +926,7 @@ paths: $ref: "#/definitions/OuterString" x-exportParamName: "Body" responses: - 200: + "200": description: "Output string" schema: $ref: "#/definitions/OuterString" @@ -945,7 +945,7 @@ paths: $ref: "#/definitions/OuterBoolean" x-exportParamName: "Body" responses: - 200: + "200": description: "Output boolean" schema: $ref: "#/definitions/OuterBoolean" @@ -964,7 +964,7 @@ paths: $ref: "#/definitions/OuterComposite" x-exportParamName: "Body" responses: - 200: + "200": description: "Output composite" schema: $ref: "#/definitions/OuterComposite" @@ -991,7 +991,7 @@ paths: type: "string" x-exportParamName: "Param2" responses: - 200: + "200": description: "successful operation" /fake/inline-additionalProperties: post: @@ -1013,7 +1013,7 @@ paths: type: "string" x-exportParamName: "Param" responses: - 200: + "200": description: "successful operation" /fake/body-with-query-params: put: @@ -1035,7 +1035,7 @@ paths: type: "string" x-exportParamName: "Query" responses: - 200: + "200": description: "Success" /another-fake/dummy: patch: @@ -1057,7 +1057,7 @@ paths: $ref: "#/definitions/Client" x-exportParamName: "Body" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Client" @@ -1269,13 +1269,13 @@ definitions: readOnly: true property: type: "string" - 123Number: + "123Number": type: "integer" readOnly: true xml: name: "Name" description: "Model for testing model name same as property name" - 200_response: + "200_response": properties: name: type: "integer" @@ -1444,7 +1444,7 @@ definitions: List: type: "object" properties: - 123-list: + "123-list": type: "string" Client: type: "object" diff --git a/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go b/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go index e5a0fb71ea3..89e7e97727b 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go @@ -26,7 +26,7 @@ var ( 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(). @@ -88,9 +88,7 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -115,3 +113,4 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore-withXml/api_fake.go b/samples/client/petstore/go/go-petstore-withXml/api_fake.go index fc269978e18..b4ed102daf4 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_fake.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_fake.go @@ -27,7 +27,7 @@ var ( 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(). @@ -102,9 +102,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -130,7 +128,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar 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(). @@ -205,9 +203,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -233,7 +229,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV 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(). @@ -308,9 +304,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -336,7 +330,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO 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(). @@ -411,9 +405,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -439,7 +431,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO 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 @@ -512,7 +504,7 @@ func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, body User, 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(). @@ -574,9 +566,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -602,7 +592,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie 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(). @@ -746,7 +736,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa 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(). @@ -860,7 +850,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona 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(). @@ -932,7 +922,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par 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(). @@ -1004,3 +994,4 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par return localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go b/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go index d3cffa7e917..6dc2f67b0a3 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go @@ -26,7 +26,7 @@ var ( 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(). @@ -101,9 +101,7 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -128,3 +126,4 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore-withXml/api_pet.go b/samples/client/petstore/go/go-petstore-withXml/api_pet.go index 631ad3eaccf..1d1fd3cfb5d 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_pet.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_pet.go @@ -29,7 +29,7 @@ var ( 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(). @@ -101,7 +101,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e 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(). @@ -182,7 +182,7 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti 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(). @@ -243,9 +243,7 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -271,7 +269,7 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( 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(). @@ -332,9 +330,7 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -360,7 +356,7 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe 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(). @@ -434,9 +430,7 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -462,7 +456,7 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http 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(). @@ -534,7 +528,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response 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(). @@ -620,7 +614,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca 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(). @@ -674,7 +668,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt if localVarOptionals != nil && localVarOptionals.AdditionalMetadata.IsSet() { localVarFormParams.Add("additionalMetadata", parameterToString(localVarOptionals.AdditionalMetadata.Value(), "")) } - var localVarFile *os.File + var localVarFile *os.File if localVarOptionals != nil && localVarOptionals.File.IsSet() { localVarFileOk := false localVarFile, localVarFileOk = localVarOptionals.File.Value().(*os.File) @@ -707,9 +701,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -734,3 +726,4 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore-withXml/api_store.go b/samples/client/petstore/go/go-petstore-withXml/api_store.go index 400765f4981..92e538eddff 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_store.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_store.go @@ -27,7 +27,7 @@ var ( 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(). @@ -98,7 +98,7 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*htt 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(). @@ -170,9 +170,7 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, * 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -198,7 +196,7 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, * 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(). @@ -265,9 +263,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -293,7 +289,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde 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(). @@ -355,9 +351,7 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *h 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -382,3 +376,4 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *h return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore-withXml/api_user.go b/samples/client/petstore/go/go-petstore-withXml/api_user.go index 9f11693bfc4..a80240c9ca3 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_user.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_user.go @@ -27,7 +27,7 @@ var ( 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(). @@ -99,7 +99,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo 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(). @@ -171,7 +171,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U 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(). @@ -243,7 +243,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us 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(). @@ -314,7 +314,7 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http 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(). @@ -375,9 +375,7 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -403,7 +401,7 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us 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(). @@ -466,9 +464,7 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -494,7 +490,7 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor 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(). @@ -563,7 +559,7 @@ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) 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(). @@ -636,3 +632,4 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U return localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore-withXml/client.go b/samples/client/petstore/go/go-petstore-withXml/client.go index 3c9aacc301c..4c15f024f11 100644 --- a/samples/client/petstore/go/go-petstore-withXml/client.go +++ b/samples/client/petstore/go/go-petstore-withXml/client.go @@ -34,8 +34,8 @@ import ( ) var ( - jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") + 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 @@ -197,7 +197,7 @@ func (c *APIClient) prepareRequest( } // add form parameters and file if available. - if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") } @@ -236,6 +236,16 @@ func (c *APIClient) prepareRequest( w.Close() } + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + // Setup path and query parameters url, err := url.Parse(path) if err != nil { @@ -477,4 +487,4 @@ func (e GenericSwaggerError) Body() []byte { // 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/.swagger-codegen/VERSION b/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION index be9d3ebd547..0443c4ad098 100644 --- a/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION +++ b/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.13-SNAPSHOT \ No newline at end of file +2.4.16-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index d3d111dda49..dc14850d4b0 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -64,9 +64,11 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [Capitalization](docs/Capitalization.md) + - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) + - [Dog](docs/Dog.md) - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) @@ -91,8 +93,6 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [Tag](docs/Tag.md) - [User](docs/User.md) - - [Cat](docs/Cat.md) - - [Dog](docs/Dog.md) ## Documentation For Authorization diff --git a/samples/client/petstore/go/go-petstore/api_another_fake.go b/samples/client/petstore/go/go-petstore/api_another_fake.go index e5a0fb71ea3..89e7e97727b 100644 --- a/samples/client/petstore/go/go-petstore/api_another_fake.go +++ b/samples/client/petstore/go/go-petstore/api_another_fake.go @@ -26,7 +26,7 @@ var ( 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(). @@ -88,9 +88,7 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -115,3 +113,4 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go index fc269978e18..b4ed102daf4 100644 --- a/samples/client/petstore/go/go-petstore/api_fake.go +++ b/samples/client/petstore/go/go-petstore/api_fake.go @@ -27,7 +27,7 @@ var ( 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(). @@ -102,9 +102,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -130,7 +128,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar 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(). @@ -205,9 +203,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -233,7 +229,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV 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(). @@ -308,9 +304,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -336,7 +330,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO 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(). @@ -411,9 +405,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -439,7 +431,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO 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 @@ -512,7 +504,7 @@ func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, body User, 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(). @@ -574,9 +566,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -602,7 +592,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie 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(). @@ -746,7 +736,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa 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(). @@ -860,7 +850,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona 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(). @@ -932,7 +922,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par 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(). @@ -1004,3 +994,4 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par return localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go b/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go index d3cffa7e917..6dc2f67b0a3 100644 --- a/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go +++ b/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go @@ -26,7 +26,7 @@ var ( 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(). @@ -101,9 +101,7 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -128,3 +126,4 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore/api_pet.go b/samples/client/petstore/go/go-petstore/api_pet.go index 960a5f994e3..1d1fd3cfb5d 100644 --- a/samples/client/petstore/go/go-petstore/api_pet.go +++ b/samples/client/petstore/go/go-petstore/api_pet.go @@ -29,7 +29,7 @@ var ( 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(). @@ -101,7 +101,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e 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(). @@ -182,7 +182,7 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti 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(). @@ -243,9 +243,7 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -271,7 +269,7 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( 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(). @@ -332,9 +330,7 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -360,7 +356,7 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe 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(). @@ -434,9 +430,7 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -462,7 +456,7 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http 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(). @@ -534,7 +528,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response 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(). @@ -620,7 +614,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca 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(). @@ -707,9 +701,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -734,3 +726,4 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore/api_store.go b/samples/client/petstore/go/go-petstore/api_store.go index 400765f4981..92e538eddff 100644 --- a/samples/client/petstore/go/go-petstore/api_store.go +++ b/samples/client/petstore/go/go-petstore/api_store.go @@ -27,7 +27,7 @@ var ( 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(). @@ -98,7 +98,7 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*htt 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(). @@ -170,9 +170,7 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, * 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -198,7 +196,7 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, * 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(). @@ -265,9 +263,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -293,7 +289,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde 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(). @@ -355,9 +351,7 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *h 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -382,3 +376,4 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *h return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore/api_user.go b/samples/client/petstore/go/go-petstore/api_user.go index 9f11693bfc4..a80240c9ca3 100644 --- a/samples/client/petstore/go/go-petstore/api_user.go +++ b/samples/client/petstore/go/go-petstore/api_user.go @@ -27,7 +27,7 @@ var ( 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(). @@ -99,7 +99,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo 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(). @@ -171,7 +171,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U 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(). @@ -243,7 +243,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us 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(). @@ -314,7 +314,7 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http 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(). @@ -375,9 +375,7 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -403,7 +401,7 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us 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(). @@ -466,9 +464,7 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor 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 - } + return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode >= 300 { @@ -494,7 +490,7 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor 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(). @@ -563,7 +559,7 @@ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) 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(). @@ -636,3 +632,4 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U return localVarHttpResponse, nil } + diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go index 52b150cfc51..4c15f024f11 100644 --- a/samples/client/petstore/go/go-petstore/client.go +++ b/samples/client/petstore/go/go-petstore/client.go @@ -34,8 +34,8 @@ import ( ) var ( - jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") + 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