diff --git a/examples/internal/clients/abe/.swagger-codegen/VERSION b/examples/internal/clients/abe/.swagger-codegen/VERSION index 752a79ef362..a932b445646 100644 --- a/examples/internal/clients/abe/.swagger-codegen/VERSION +++ b/examples/internal/clients/abe/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8 \ No newline at end of file +2.4.47-SNAPSHOT \ No newline at end of file diff --git a/examples/internal/clients/abe/BUILD.bazel b/examples/internal/clients/abe/BUILD.bazel index 806b3cef3dc..993f5f0e066 100644 --- a/examples/internal/clients/abe/BUILD.bazel +++ b/examples/internal/clients/abe/BUILD.bazel @@ -57,6 +57,8 @@ go_library( "model_the_book_to_update_the_books_name_field_is_used_to_identify_the_book_to_be_updated_format_publisherspublisherbooksbook.go", "model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask.go", "model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask_1.go", + "model_v1_book_name_body.go", + "model_v1_book_name_body_1.go", "model_v1exampledeep_pathsingle_nested_name_single_nested.go", "response.go", ], diff --git a/examples/internal/clients/abe/api/swagger.yaml b/examples/internal/clients/abe/api/swagger.yaml index 79cf407779d..636ded31105 100644 --- a/examples/internal/clients/abe/api/swagger.yaml +++ b/examples/internal/clients/abe/api/swagger.yaml @@ -57,24 +57,24 @@ paths: $ref: "#/definitions/examplepbABitOfEverything" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -95,32 +95,35 @@ paths: required: true type: "string" x-exportParamName: "Value" + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" responses: - 200: + "200": description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/subStringMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" - 503: + "503": description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 @@ -128,9 +131,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - externalDocs: - description: "Find out more Echo" - url: "https://github.com/grpc-ecosystem/grpc-gateway" /v1/example/a_bit_of_everything/params/get/nested_enum/{singleNested.ok}: get: tags: @@ -518,24 +518,24 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -937,24 +937,24 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -1343,24 +1343,24 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -1768,25 +1768,30 @@ paths: format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" + security: [] + externalDocs: + description: "Find out more about GetQuery" + url: "https://github.com/grpc-ecosystem/grpc-gateway" + deprecated: true responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -1794,11 +1799,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - security: [] - externalDocs: - description: "Find out more about GetQuery" - url: "https://github.com/grpc-ecosystem/grpc-gateway" - deprecated: true ? /v1/example/a_bit_of_everything/{floatValue}/{doubleValue}/{int64Value}/separator/{uint64Value}/{int32Value}/{fixed64Value}/{fixed32Value}/{boolValue}/{stringValue}/{uint32Value}/{sfixed32Value}/{sfixed64Value}/{sint32Value}/{sint64Value}/{nonConventionalNameValue}/{enumValue}/{pathEnumValue}/{nestedPathEnumValue}/{enumValueAnnotation} : post: tags: @@ -2182,24 +2182,24 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -2608,7 +2608,7 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: type: "object" @@ -2635,24 +2635,24 @@ paths: $ref: "#/definitions/examplepbABitOfEverythingServiceUpdateBody" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -3060,7 +3060,7 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: type: "object" @@ -3469,24 +3469,24 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -3895,24 +3895,24 @@ paths: collectionFormat: "multi" x-exportParamName: "Uuids" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -3932,24 +3932,24 @@ paths: type: "string" x-exportParamName: "Uuid" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -3967,25 +3967,30 @@ paths: required: true type: "string" x-exportParamName: "Uuid" + security: + - ApiKeyAuth: [] + OAuth2: + - "read" + - "write" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -3993,11 +3998,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - security: - - ApiKeyAuth: [] - OAuth2: - - "read" - - "write" x-irreversible: true ? /v1/example/a_bit_of_everything_repeated/{pathRepeatedFloatValue}/{pathRepeatedDoubleValue}/{pathRepeatedInt64Value}/{pathRepeatedUint64Value}/{pathRepeatedInt32Value}/{pathRepeatedFixed64Value}/{pathRepeatedFixed32Value}/{pathRepeatedBoolValue}/{pathRepeatedStringValue}/{pathRepeatedBytesValue}/{pathRepeatedUint32Value}/{pathRepeatedEnumValue}/{pathRepeatedSfixed32Value}/{pathRepeatedSfixed64Value}/{pathRepeatedSint32Value}/{pathRepeatedSint64Value} : get: @@ -4168,24 +4168,24 @@ paths: minItems: 1 x-exportParamName: "PathRepeatedSint64Value" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverythingRepeated" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4200,24 +4200,24 @@ paths: operationId: "ABitOfEverythingService_CheckStatus" parameters: [] responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbCheckStatusResponse" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4244,24 +4244,24 @@ paths: $ref: "#/definitions/ABitOfEverythingServiceDeepPathEchoBody" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4282,24 +4282,24 @@ paths: $ref: "#/definitions/oneofenumExampleEnum" x-exportParamName: "ExampleEnum" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4320,24 +4320,24 @@ paths: $ref: "#/definitions/examplepbRequiredMessageTypeRequest" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4376,24 +4376,24 @@ paths: - "value_y" x-exportParamName: "Where" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSnakeEnumResponse" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4421,7 +4421,7 @@ paths: \ the book to be updated.\nFormat: publishers/{publisher}/books/{book}" required: true schema: - $ref: "The book to update." + $ref: "#/definitions/book" x-exportParamName: "Book" - name: "allowMissing" in: "query" @@ -4432,24 +4432,24 @@ paths: x-exportParamName: "AllowMissing" x-optionalDataType: "Bool" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbBook" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4488,24 +4488,24 @@ paths: x-exportParamName: "BookId" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbBook" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4542,24 +4542,24 @@ paths: x-exportParamName: "UpdateMask" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4588,24 +4588,24 @@ paths: $ref: "#/definitions/A bit of everything_1" x-exportParamName: "Abe" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4627,32 +4627,35 @@ paths: type: "string" x-exportParamName: "Value" x-optionalDataType: "String" + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" responses: - 200: + "200": description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/subStringMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" - 503: + "503": description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 @@ -4660,9 +4663,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - externalDocs: - description: "Find out more Echo" - url: "https://github.com/grpc-ecosystem/grpc-gateway" post: tags: - "echo rpc" @@ -4676,32 +4676,35 @@ paths: schema: type: "string" x-exportParamName: "Value" + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" responses: - 200: + "200": description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/subStringMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" - 503: + "503": description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 @@ -4709,9 +4712,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - externalDocs: - description: "Find out more Echo" - url: "https://github.com/grpc-ecosystem/grpc-gateway" /v2/example/empty: get: tags: @@ -4719,24 +4719,24 @@ paths: operationId: "camelCaseServiceName_Empty" parameters: [] responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4751,24 +4751,24 @@ paths: operationId: "ABitOfEverythingService_ErrorWithDetails" parameters: [] responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4791,24 +4791,24 @@ paths: $ref: "#/definitions/examplepbBody" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4825,24 +4825,24 @@ paths: - "application/text" parameters: [] responses: - 200: + "200": description: "A successful response." schema: type: "string" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4868,24 +4868,24 @@ paths: $ref: "#/definitions/ABitOfEverythingServicePostWithEmptyBodyBody" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4900,24 +4900,24 @@ paths: operationId: "ABitOfEverythingService_Timeout" parameters: [] responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4943,24 +4943,24 @@ paths: $ref: "#/definitions/examplepbBody" x-exportParamName: "Data" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -4983,24 +4983,24 @@ paths: - "DEF" x-exportParamName: "Value" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -5028,24 +5028,24 @@ paths: $ref: "#/definitions/ABitOfEverythingServiceUpdateV2Body" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -5068,24 +5068,24 @@ paths: - "JKL" x-exportParamName: "Value" responses: - 200: + "200": description: "A successful response." schema: type: "object" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" format: "string" - 418: + "418": description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" - 500: + "500": description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" @@ -6086,7 +6086,7 @@ definitions: properties: value: type: "string" - The book to update.: + book: type: "object" properties: id: @@ -6098,9 +6098,8 @@ definitions: format: "date-time" description: "Output only. Creation time of the book." readOnly: true - title: "The book to update." - description: "The book's `name` field is used to identify the book to be updated.\n\ - Format: publishers/{publisher}/books/{book}" + description: "An example resource type from AIP-123 used to test the behavior\ + \ described in\nthe CreateBookRequest message.\n\nSee: https://google.aip.dev/123" A bit of everything: type: "object" required: @@ -6490,6 +6489,7 @@ definitions: double_value: 12.3 x-a-bit-of-everything-foo: "bar" ABitOfEverythingServiceDeepPathEchoBody_singleNested: + type: "object" properties: amount: type: "integer" @@ -6500,6 +6500,7 @@ definitions: description: "Nested is nested type." example: "{\"ok\":\"TRUE\"}" A bit of everything_2: + type: "object" properties: singleNested: $ref: "#/definitions/ABitOfEverythingNested" @@ -6676,6 +6677,7 @@ definitions: description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: "{\"int64_value\":12,\"double_value\":12.3}" + x-a-bit-of-everything-foo: "bar" externalDocs: description: "More about gRPC-Gateway" url: "https://github.com/grpc-ecosystem/grpc-gateway" diff --git a/examples/internal/clients/abe/api_a_bit_of_everything.go b/examples/internal/clients/abe/api_a_bit_of_everything.go index c072d76c84f..a9963811995 100644 --- a/examples/internal/clients/abe/api_a_bit_of_everything.go +++ b/examples/internal/clients/abe/api_a_bit_of_everything.go @@ -1,3 +1,4 @@ + /* * A Bit of Everything * @@ -27,7 +28,7 @@ var ( type ABitOfEverythingApiService service -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param value @@ -100,9 +101,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckExternalNestedP 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 { @@ -183,7 +182,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckExternalNestedP return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param value @@ -256,9 +255,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckExternalPathEnu 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 { @@ -339,7 +336,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckExternalPathEnu return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param singleNestedName name is nested field. @@ -352,7 +349,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceCheckGetQueryParamsOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCheckGetQueryParamsOpts - Optional Parameters: * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - @@ -398,7 +395,7 @@ ABitOfEverythingApiService @return ExamplepbABitOfEverything */ -type ABitOfEverythingServiceCheckGetQueryParamsOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCheckGetQueryParamsOpts struct { SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String @@ -442,7 +439,7 @@ type ABitOfEverythingServiceCheckGetQueryParamsOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckGetQueryParams(ctx context.Context, singleNestedName string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckGetQueryParams(ctx context.Context, singleNestedName string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCheckGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -640,9 +637,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckGetQueryParams( 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 { @@ -723,7 +718,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckGetQueryParams( return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param singleNestedOk DeepEnum description. @@ -736,7 +731,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "Uint64Value" (optional.String) - @@ -782,7 +777,7 @@ ABitOfEverythingApiService @return ExamplepbABitOfEverything */ -type ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 Uint64Value optional.String @@ -826,7 +821,7 @@ type ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckNestedEnumGetQueryParams(ctx context.Context, singleNestedOk string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckNestedEnumGetQueryParams(ctx context.Context, singleNestedOk string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -1024,9 +1019,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckNestedEnumGetQu 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 { @@ -1107,7 +1100,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckNestedEnumGetQu return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param stringValue @@ -1121,7 +1114,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceCheckPostQueryParamsOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCheckPostQueryParamsOpts - Optional Parameters: * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - @@ -1165,7 +1158,7 @@ ABitOfEverythingApiService @return ExamplepbABitOfEverything */ -type ABitOfEverythingServiceCheckPostQueryParamsOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCheckPostQueryParamsOpts struct { Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String @@ -1207,7 +1200,7 @@ type ABitOfEverythingServiceCheckPostQueryParamsOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckPostQueryParams(ctx context.Context, stringValue string, singleNested ABitOfEverythingNested, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckPostQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckPostQueryParams(ctx context.Context, stringValue string, singleNested ABitOfEverythingNested, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCheckPostQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -1401,9 +1394,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckPostQueryParams 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 { @@ -1484,7 +1475,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckPostQueryParams return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -1555,9 +1546,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckStatus(ctx cont 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 { @@ -1638,7 +1627,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckStatus(ctx cont return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService Create a new ABitOfEverything This API creates a new ABitOfEverything * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -1667,7 +1656,7 @@ This API creates a new ABitOfEverything * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceCreateOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCreateOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. @@ -1699,7 +1688,7 @@ This API creates a new ABitOfEverything @return ExamplepbABitOfEverything */ -type ABitOfEverythingServiceCreateOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCreateOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String @@ -1729,7 +1718,7 @@ type ABitOfEverythingServiceCreateOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreate(ctx context.Context, floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string, enumValueAnnotation string, uuid string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCreateOpts) (ExamplepbABitOfEverything, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreate(ctx context.Context, floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string, enumValueAnnotation string, uuid string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCreateOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -1900,9 +1889,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreate(ctx context.C 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 { @@ -1983,7 +1970,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreate(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body Intentionally complicated message type to cover many features of Protobuf. @@ -2057,9 +2044,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBody(ctx conte 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 { @@ -2140,22 +2125,22 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBody(ctx conte return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService Create a book. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param parent The publisher in which to create the book. Format: `publishers/{publisher}` Example: `publishers/1257894000000000000` * @param book The book to create. - * @param optional nil or *ABitOfEverythingServiceCreateBookOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCreateBookOpts - Optional Parameters: * @param "BookId" (optional.String) - The ID to use for the book. This must start with an alphanumeric character. @return ExamplepbBook */ -type ABitOfEverythingServiceCreateBookOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCreateBookOpts struct { BookId optional.String } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBook(ctx context.Context, parent string, book ExamplepbBook, localVarOptionals *ABitOfEverythingServiceCreateBookOpts) (ExamplepbBook, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBook(ctx context.Context, parent string, book ExamplepbBook, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCreateBookOpts) (ExamplepbBook, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -2226,9 +2211,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBook(ctx conte 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 { @@ -2309,7 +2292,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBook(ctx conte return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -2321,7 +2304,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceCustomOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCustomOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. @@ -2369,7 +2352,7 @@ ABitOfEverythingApiService @return ExamplepbABitOfEverything */ -type ABitOfEverythingServiceCustomOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCustomOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String @@ -2415,7 +2398,7 @@ type ABitOfEverythingServiceCustomOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustom(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustomOpts) (ExamplepbABitOfEverything, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustom(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCustomOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -2618,9 +2601,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustom(ctx context.C 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 { @@ -2701,7 +2682,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustom(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -2713,7 +2694,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceCustomOptionsRequestOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceCustomOptionsRequestOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. @@ -2761,7 +2742,7 @@ ABitOfEverythingApiService @return interface{} */ -type ABitOfEverythingServiceCustomOptionsRequestOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceCustomOptionsRequestOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String @@ -2807,7 +2788,7 @@ type ABitOfEverythingServiceCustomOptionsRequestOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustomOptionsRequest(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustomOptionsRequestOpts) (interface{}, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustomOptionsRequest(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceCustomOptionsRequestOpts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Options") localVarPostBody interface{} @@ -3010,9 +2991,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustomOptionsRequest 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 { @@ -3049,7 +3028,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustomOptionsRequest return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param singleNestedName name is nested field. @@ -3125,9 +3104,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDeepPathEcho(ctx con 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 { @@ -3208,7 +3185,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDeepPathEcho(ctx con return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuid @@ -3281,9 +3258,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDelete(ctx context.C 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 { @@ -3364,7 +3339,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDelete(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -3376,7 +3351,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceDoubleColonOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceDoubleColonOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. @@ -3424,7 +3399,7 @@ ABitOfEverythingApiService @return ExamplepbABitOfEverything */ -type ABitOfEverythingServiceDoubleColonOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceDoubleColonOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String @@ -3470,7 +3445,7 @@ type ABitOfEverythingServiceDoubleColonOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDoubleColon(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceDoubleColonOpts) (ExamplepbABitOfEverything, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDoubleColon(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceDoubleColonOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -3673,9 +3648,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDoubleColon(ctx cont 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 { @@ -3756,7 +3729,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDoubleColon(ctx cont return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -3827,9 +3800,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceErrorWithDetails(ctx 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 { @@ -3910,7 +3881,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceErrorWithDetails(ctx return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -3922,7 +3893,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceExistsOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceExistsOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. @@ -3970,7 +3941,7 @@ ABitOfEverythingApiService @return interface{} */ -type ABitOfEverythingServiceExistsOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceExistsOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String @@ -4016,7 +3987,7 @@ type ABitOfEverythingServiceExistsOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceExists(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceExistsOpts) (interface{}, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceExists(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceExistsOpts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Head") localVarPostBody interface{} @@ -4219,9 +4190,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceExists(ctx context.C 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 { @@ -4258,7 +4227,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceExists(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id @@ -4334,9 +4303,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetMessageWithBody(c 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 { @@ -4417,7 +4384,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetMessageWithBody(c return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -4429,7 +4396,7 @@ ABitOfEverythingApiService * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom - * @param optional nil or *ABitOfEverythingServiceGetQueryOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceGetQueryOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. @@ -4477,7 +4444,7 @@ ABitOfEverythingApiService @return interface{} */ -type ABitOfEverythingServiceGetQueryOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceGetQueryOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String @@ -4523,7 +4490,7 @@ type ABitOfEverythingServiceGetQueryOpts struct { Uuids optional.Interface } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetQuery(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceGetQueryOpts) (interface{}, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetQuery(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceGetQueryOpts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -4713,9 +4680,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetQuery(ctx context 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 { @@ -4796,7 +4761,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetQuery(ctx context return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param pathRepeatedFloatValue repeated values. they are comma-separated in path @@ -4947,9 +4912,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetRepeatedQuery(ctx 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 { @@ -5030,7 +4993,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetRepeatedQuery(ctx return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuid @@ -5103,9 +5066,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceLookup(ctx context.C 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 { @@ -5186,7 +5147,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceLookup(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body @@ -5260,9 +5221,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceOverwriteRequestCont 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 { @@ -5343,7 +5302,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceOverwriteRequestCont return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -5414,9 +5373,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceOverwriteResponseCon 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 { @@ -5497,7 +5454,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceOverwriteResponseCon return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param exampleEnum @@ -5571,9 +5528,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostOneofEnum(ctx co 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 { @@ -5654,7 +5609,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostOneofEnum(ctx co return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body @@ -5728,9 +5683,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostRequiredMessageT 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 { @@ -5811,7 +5764,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostRequiredMessageT return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param name @@ -5887,9 +5840,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostWithEmptyBody(ct 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 { @@ -5970,7 +5921,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostWithEmptyBody(ct return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -6041,9 +5992,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceTimeout(ctx context. 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 { @@ -6124,7 +6073,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceTimeout(ctx context. return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -6200,9 +6149,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdate(ctx context.C 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 { @@ -6283,22 +6230,22 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdate(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param bookName The resource name of the book. Format: `publishers/{publisher}/books/{book}` Example: `publishers/1257894000000000000/books/my-book` * @param book The book to update. The book's `name` field is used to identify the book to be updated. Format: publishers/{publisher}/books/{book} - * @param optional nil or *ABitOfEverythingServiceUpdateBookOpts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceUpdateBookOpts - Optional Parameters: * @param "AllowMissing" (optional.Bool) - If set to true, and the book is not found, a new book will be created. In this situation, `update_mask` is ignored. @return ExamplepbBook */ -type ABitOfEverythingServiceUpdateBookOpts struct { +type ABitOfEverythingApiABitOfEverythingServiceUpdateBookOpts struct { AllowMissing optional.Bool } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateBook(ctx context.Context, bookName string, book TheBookToUpdate_, localVarOptionals *ABitOfEverythingServiceUpdateBookOpts) (ExamplepbBook, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateBook(ctx context.Context, bookName string, book Book, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceUpdateBookOpts) (ExamplepbBook, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} @@ -6369,9 +6316,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateBook(ctx conte 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 { @@ -6452,22 +6397,22 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateBook(ctx conte return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param abe A bit of everything Intentionally complicated message type to cover many features of Protobuf. - * @param optional nil or *ABitOfEverythingServiceUpdateV2Opts - Optional Parameters: + * @param optional nil or *ABitOfEverythingApiABitOfEverythingServiceUpdateV2Opts - Optional Parameters: * @param "UpdateMask" (optional.String) - The paths to update. @return interface{} */ -type ABitOfEverythingServiceUpdateV2Opts struct { +type ABitOfEverythingApiABitOfEverythingServiceUpdateV2Opts struct { UpdateMask optional.String } -func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV2(ctx context.Context, uuidName string, abe ABitOfEverything, localVarOptionals *ABitOfEverythingServiceUpdateV2Opts) (interface{}, *http.Response, error) { +func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV2(ctx context.Context, uuidName string, abe ABitOfEverything, localVarOptionals *ABitOfEverythingApiABitOfEverythingServiceUpdateV2Opts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} @@ -6538,9 +6483,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV2(ctx context 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 { @@ -6621,7 +6564,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV2(ctx context return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -6697,9 +6640,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV22(ctx contex 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 { @@ -6780,7 +6721,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV22(ctx contex return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName @@ -6856,9 +6797,7 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV23(ctx contex 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 { @@ -6938,3 +6877,4 @@ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV23(ctx contex return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/abe/api_camel_case_service_name.go b/examples/internal/clients/abe/api_camel_case_service_name.go index ea4269f06b4..e687b47d481 100644 --- a/examples/internal/clients/abe/api_camel_case_service_name.go +++ b/examples/internal/clients/abe/api_camel_case_service_name.go @@ -1,3 +1,4 @@ + /* * A Bit of Everything * @@ -25,7 +26,7 @@ var ( type CamelCaseServiceNameApiService service -/* +/* CamelCaseServiceNameApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -96,9 +97,7 @@ func (a *CamelCaseServiceNameApiService) CamelCaseServiceNameEmpty(ctx context.C 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 { @@ -178,3 +177,4 @@ func (a *CamelCaseServiceNameApiService) CamelCaseServiceNameEmpty(ctx context.C return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/abe/api_echo_rpc.go b/examples/internal/clients/abe/api_echo_rpc.go index 1578fbff89b..addb5bbfb34 100644 --- a/examples/internal/clients/abe/api_echo_rpc.go +++ b/examples/internal/clients/abe/api_echo_rpc.go @@ -1,3 +1,4 @@ + /* * A Bit of Everything * @@ -27,7 +28,7 @@ var ( type EchoRpcApiService service -/* +/* EchoRpcApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -101,9 +102,7 @@ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho(ctx context.Context, val 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 { @@ -195,7 +194,7 @@ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho(ctx context.Context, val return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoRpcApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -270,9 +269,7 @@ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho2(ctx context.Context, va 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 { @@ -364,21 +361,21 @@ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho2(ctx context.Context, va return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoRpcApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *ABitOfEverythingServiceEcho3Opts - Optional Parameters: + * @param optional nil or *EchoRpcApiABitOfEverythingServiceEcho3Opts - Optional Parameters: * @param "Value" (optional.String) - @return SubStringMessage */ -type ABitOfEverythingServiceEcho3Opts struct { +type EchoRpcApiABitOfEverythingServiceEcho3Opts struct { Value optional.String } -func (a *EchoRpcApiService) ABitOfEverythingServiceEcho3(ctx context.Context, localVarOptionals *ABitOfEverythingServiceEcho3Opts) (SubStringMessage, *http.Response, error) { +func (a *EchoRpcApiService) ABitOfEverythingServiceEcho3(ctx context.Context, localVarOptionals *EchoRpcApiABitOfEverythingServiceEcho3Opts) (SubStringMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -446,9 +443,7 @@ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho3(ctx context.Context, lo 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 { @@ -539,3 +534,4 @@ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho3(ctx context.Context, lo return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/abe/api_snake_enum_service.go b/examples/internal/clients/abe/api_snake_enum_service.go index 0c28d4ab4f4..d8b9794f718 100644 --- a/examples/internal/clients/abe/api_snake_enum_service.go +++ b/examples/internal/clients/abe/api_snake_enum_service.go @@ -1,3 +1,4 @@ + /* * A Bit of Everything * @@ -26,7 +27,7 @@ var ( type SnakeEnumServiceApiService service -/* +/* SnakeEnumServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param who @@ -103,9 +104,7 @@ func (a *SnakeEnumServiceApiService) SnakeEnumServiceSnakeEnum(ctx context.Conte 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 { @@ -185,3 +184,4 @@ func (a *SnakeEnumServiceApiService) SnakeEnumServiceSnakeEnum(ctx context.Conte return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/abe/client.go b/examples/internal/clients/abe/client.go index 3293aadf212..0a2a703900b 100644 --- a/examples/internal/clients/abe/client.go +++ b/examples/internal/clients/abe/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 A Bit of Everything API v1.0 @@ -191,7 +191,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.") } @@ -230,6 +230,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 { @@ -471,4 +481,5 @@ 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/examples/internal/clients/abe/model_a_bit_of_everything.go b/examples/internal/clients/abe/model_a_bit_of_everything.go index 80fe399f711..73426b5dd88 100644 --- a/examples/internal/clients/abe/model_a_bit_of_everything.go +++ b/examples/internal/clients/abe/model_a_bit_of_everything.go @@ -38,7 +38,7 @@ type ABitOfEverything struct { Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` - OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` + OneofEmpty interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. diff --git a/examples/internal/clients/abe/model_a_bit_of_everything_1.go b/examples/internal/clients/abe/model_a_bit_of_everything_1.go index bef01473473..417f8a3287b 100644 --- a/examples/internal/clients/abe/model_a_bit_of_everything_1.go +++ b/examples/internal/clients/abe/model_a_bit_of_everything_1.go @@ -38,7 +38,7 @@ type ABitOfEverything1 struct { Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` - OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` + OneofEmpty interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. diff --git a/examples/internal/clients/abe/model_a_bit_of_everything_2.go b/examples/internal/clients/abe/model_a_bit_of_everything_2.go index 62c5847f084..02677de439c 100644 --- a/examples/internal/clients/abe/model_a_bit_of_everything_2.go +++ b/examples/internal/clients/abe/model_a_bit_of_everything_2.go @@ -38,7 +38,7 @@ type ABitOfEverything2 struct { Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` - OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` + OneofEmpty interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. diff --git a/examples/internal/clients/abe/model_a_bit_of_everything_3.go b/examples/internal/clients/abe/model_a_bit_of_everything_3.go index e187a495328..ab034181653 100644 --- a/examples/internal/clients/abe/model_a_bit_of_everything_3.go +++ b/examples/internal/clients/abe/model_a_bit_of_everything_3.go @@ -7,9 +7,7 @@ * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ - package abe - import ( "time" ) @@ -41,6 +39,7 @@ type ABitOfEverything3 struct { OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` + // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` @@ -48,13 +47,11 @@ type ABitOfEverything3 struct { RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` - // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` - // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` diff --git a/examples/internal/clients/abe/model_a_bit_of_everything_4.go b/examples/internal/clients/abe/model_a_bit_of_everything_4.go index f389abd637f..193eaed9585 100644 --- a/examples/internal/clients/abe/model_a_bit_of_everything_4.go +++ b/examples/internal/clients/abe/model_a_bit_of_everything_4.go @@ -7,9 +7,7 @@ * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ - package abe - import ( "time" ) @@ -41,6 +39,7 @@ type ABitOfEverything4 struct { OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` + // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` @@ -48,13 +47,11 @@ type ABitOfEverything4 struct { RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` - // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` - // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation,omitempty"` diff --git a/examples/internal/clients/abe/model_a_bit_of_everything_service_deep_path_echo_body.go b/examples/internal/clients/abe/model_a_bit_of_everything_service_deep_path_echo_body.go index 28f63ffccdf..5fe2931e675 100644 --- a/examples/internal/clients/abe/model_a_bit_of_everything_service_deep_path_echo_body.go +++ b/examples/internal/clients/abe/model_a_bit_of_everything_service_deep_path_echo_body.go @@ -39,7 +39,7 @@ type ABitOfEverythingServiceDeepPathEchoBody struct { Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` - OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` + OneofEmpty interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. diff --git a/examples/internal/clients/abe/model_examplepb_a_bit_of_everything.go b/examples/internal/clients/abe/model_examplepb_a_bit_of_everything.go index 12a19aa4cab..4555304492c 100644 --- a/examples/internal/clients/abe/model_examplepb_a_bit_of_everything.go +++ b/examples/internal/clients/abe/model_examplepb_a_bit_of_everything.go @@ -11,9 +11,37 @@ package abe import ( + "encoding/json" + "strconv" "time" ) +// FlexibleInt64 can unmarshal from both string and int64 +type FlexibleInt64 int64 + +func (f *FlexibleInt64) UnmarshalJSON(data []byte) error { + // Try to unmarshal as int64 first + var i int64 + if err := json.Unmarshal(data, &i); err == nil { + *f = FlexibleInt64(i) + return nil + } + + // If that fails, try to unmarshal as string and convert + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + + parsed, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + + *f = FlexibleInt64(parsed) + return nil +} + // Intentionally complicated message type to cover many features of Protobuf. type ExamplepbABitOfEverything struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` @@ -39,7 +67,7 @@ type ExamplepbABitOfEverything struct { Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` - OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` + OneofEmpty interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. @@ -58,7 +86,7 @@ type ExamplepbABitOfEverything struct { RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` - Int64OverrideType int64 `json:"int64OverrideType,omitempty"` + Int64OverrideType FlexibleInt64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` diff --git a/examples/internal/clients/abe/model_examplepb_a_bit_of_everything_service_update_body.go b/examples/internal/clients/abe/model_examplepb_a_bit_of_everything_service_update_body.go index 0d41a76308f..34a955d7cfd 100644 --- a/examples/internal/clients/abe/model_examplepb_a_bit_of_everything_service_update_body.go +++ b/examples/internal/clients/abe/model_examplepb_a_bit_of_everything_service_update_body.go @@ -38,7 +38,7 @@ type ExamplepbABitOfEverythingServiceUpdateBody struct { Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` - OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` + OneofEmpty interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. diff --git a/examples/internal/clients/abe/model_v1_book_name_body.go b/examples/internal/clients/abe/model_v1_book_name_body.go new file mode 100644 index 00000000000..0eca51ce535 --- /dev/null +++ b/examples/internal/clients/abe/model_v1_book_name_body.go @@ -0,0 +1,21 @@ +/* + * A Bit of Everything + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0 + * Contact: none@example.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package abe +import ( + "time" +) + +// An example resource type from AIP-123 used to test the behavior described in the CreateBookRequest message. See: https://google.aip.dev/123 +type V1BookNameBody struct { + // Output only. The book's ID. + Id string `json:"id,omitempty"` + // Output only. Creation time of the book. + CreateTime time.Time `json:"createTime,omitempty"` +} diff --git a/examples/internal/clients/abe/model_v1_book_name_body_1.go b/examples/internal/clients/abe/model_v1_book_name_body_1.go new file mode 100644 index 00000000000..d69a8874469 --- /dev/null +++ b/examples/internal/clients/abe/model_v1_book_name_body_1.go @@ -0,0 +1,21 @@ +/* + * A Bit of Everything + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0 + * Contact: none@example.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package abe +import ( + "time" +) + +// An example resource type from AIP-123 used to test the behavior described in the CreateBookRequest message. See: https://google.aip.dev/123 +type V1BookNameBody1 struct { + // Output only. The book's ID. + Id string `json:"id,omitempty"` + // Output only. Creation time of the book. + CreateTime time.Time `json:"createTime,omitempty"` +} diff --git a/examples/internal/clients/echo/.swagger-codegen/VERSION b/examples/internal/clients/echo/.swagger-codegen/VERSION index 752a79ef362..a932b445646 100644 --- a/examples/internal/clients/echo/.swagger-codegen/VERSION +++ b/examples/internal/clients/echo/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8 \ No newline at end of file +2.4.47-SNAPSHOT \ No newline at end of file diff --git a/examples/internal/clients/echo/api/swagger.yaml b/examples/internal/clients/echo/api/swagger.yaml index a7871cf2238..cbd1a9f2745 100644 --- a/examples/internal/clients/echo/api/swagger.yaml +++ b/examples/internal/clients/echo/api/swagger.yaml @@ -97,7 +97,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -191,7 +191,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -285,7 +285,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -378,7 +378,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -470,7 +470,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -556,7 +556,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -644,7 +644,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -667,7 +667,7 @@ paths: $ref: "#/definitions/examplepbSimpleMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -746,7 +746,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -840,7 +840,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" @@ -862,7 +862,7 @@ paths: $ref: "#/definitions/examplepbDynamicMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbDynamicMessageUpdate" @@ -958,7 +958,7 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" diff --git a/examples/internal/clients/echo/api_echo_service.go b/examples/internal/clients/echo/api_echo_service.go index c5807965d34..d4c74e6e66e 100644 --- a/examples/internal/clients/echo/api_echo_service.go +++ b/examples/internal/clients/echo/api_echo_service.go @@ -1,3 +1,4 @@ + /* * Echo Service * @@ -26,12 +27,12 @@ var ( type EchoServiceApiService service -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. - * @param optional nil or *EchoServiceEchoOpts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEchoOpts - Optional Parameters: * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - @@ -47,7 +48,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEchoOpts struct { +type EchoServiceApiEchoServiceEchoOpts struct { Num optional.String LineNum optional.String Lang optional.String @@ -61,7 +62,7 @@ type EchoServiceEchoOpts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho(ctx context.Context, id string, localVarOptionals *EchoServiceEchoOpts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho(ctx context.Context, id string, localVarOptionals *EchoServiceApiEchoServiceEchoOpts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -147,9 +148,7 @@ func (a *EchoServiceApiService) EchoServiceEcho(ctx context.Context, id 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 { @@ -186,13 +185,13 @@ func (a *EchoServiceApiService) EchoServiceEcho(ctx context.Context, id string, return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num - * @param optional nil or *EchoServiceEcho2Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEcho2Opts - Optional Parameters: * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - @@ -207,7 +206,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEcho2Opts struct { +type EchoServiceApiEchoServiceEcho2Opts struct { LineNum optional.String Lang optional.String StatusProgress optional.String @@ -220,7 +219,7 @@ type EchoServiceEcho2Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho2(ctx context.Context, id string, num string, localVarOptionals *EchoServiceEcho2Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho2(ctx context.Context, id string, num string, localVarOptionals *EchoServiceApiEchoServiceEcho2Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -304,9 +303,7 @@ func (a *EchoServiceApiService) EchoServiceEcho2(ctx context.Context, id 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 { @@ -343,14 +340,14 @@ func (a *EchoServiceApiService) EchoServiceEcho2(ctx context.Context, id string, return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num * @param lang - * @param optional nil or *EchoServiceEcho3Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEcho3Opts - Optional Parameters: * @param "LineNum" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - @@ -364,7 +361,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEcho3Opts struct { +type EchoServiceApiEchoServiceEcho3Opts struct { LineNum optional.String StatusProgress optional.String StatusNote optional.String @@ -376,7 +373,7 @@ type EchoServiceEcho3Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id string, num string, lang string, localVarOptionals *EchoServiceEcho3Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id string, num string, lang string, localVarOptionals *EchoServiceApiEchoServiceEcho3Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -458,9 +455,7 @@ func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id 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 { @@ -497,14 +492,14 @@ func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id string, return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param lineNum * @param statusNote - * @param optional nil or *EchoServiceEcho4Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEcho4Opts - Optional Parameters: * @param "Num" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - @@ -517,7 +512,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEcho4Opts struct { +type EchoServiceApiEchoServiceEcho4Opts struct { Num optional.String Lang optional.String StatusProgress optional.String @@ -528,7 +523,7 @@ type EchoServiceEcho4Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id string, lineNum string, statusNote string, localVarOptionals *EchoServiceEcho4Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id string, lineNum string, statusNote string, localVarOptionals *EchoServiceApiEchoServiceEcho4Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -607,9 +602,7 @@ func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id 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 { @@ -646,12 +639,12 @@ func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id string, return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param noNote - * @param optional nil or *EchoServiceEcho5Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEcho5Opts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - @@ -666,7 +659,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEcho5Opts struct { +type EchoServiceApiEchoServiceEcho5Opts struct { Id optional.String Num optional.String LineNum optional.String @@ -679,7 +672,7 @@ type EchoServiceEcho5Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote string, localVarOptionals *EchoServiceEcho5Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote string, localVarOptionals *EchoServiceApiEchoServiceEcho5Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -762,9 +755,7 @@ func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote str 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 { @@ -801,12 +792,12 @@ func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote str return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param resourceId - * @param optional nil or *EchoServiceEcho6Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEcho6Opts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - @@ -822,7 +813,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEcho6Opts struct { +type EchoServiceApiEchoServiceEcho6Opts struct { Id optional.String Num optional.String LineNum optional.String @@ -836,7 +827,7 @@ type EchoServiceEcho6Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho6(ctx context.Context, resourceId string, localVarOptionals *EchoServiceEcho6Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho6(ctx context.Context, resourceId string, localVarOptionals *EchoServiceApiEchoServiceEcho6Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -922,9 +913,7 @@ func (a *EchoServiceApiService) EchoServiceEcho6(ctx context.Context, resourceId 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 { @@ -961,12 +950,12 @@ func (a *EchoServiceApiService) EchoServiceEcho6(ctx context.Context, resourceId return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param nIdNId - * @param optional nil or *EchoServiceEcho7Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEcho7Opts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - @@ -982,7 +971,7 @@ The message posted as the id parameter will also be returned. @return ExamplepbSimpleMessage */ -type EchoServiceEcho7Opts struct { +type EchoServiceApiEchoServiceEcho7Opts struct { Id optional.String Num optional.String LineNum optional.String @@ -996,7 +985,7 @@ type EchoServiceEcho7Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEcho7(ctx context.Context, nIdNId string, localVarOptionals *EchoServiceEcho7Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEcho7(ctx context.Context, nIdNId string, localVarOptionals *EchoServiceApiEchoServiceEcho7Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -1082,9 +1071,7 @@ func (a *EchoServiceApiService) EchoServiceEcho7(ctx context.Context, nIdNId str 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 { @@ -1121,7 +1108,7 @@ func (a *EchoServiceApiService) EchoServiceEcho7(ctx context.Context, nIdNId str return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body SimpleMessage represents a simple message sent to the Echo service. @@ -1182,9 +1169,7 @@ func (a *EchoServiceApiService) EchoServiceEchoBody(ctx context.Context, body Ex 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 { @@ -1221,12 +1206,12 @@ func (a *EchoServiceApiService) EchoServiceEchoBody(ctx context.Context, body Ex return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param no - * @param optional nil or *EchoServiceEchoBody2Opts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEchoBody2Opts - Optional Parameters: * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - @@ -1239,7 +1224,7 @@ EchoServiceApiService EchoBody method receives a simple message and returns it. @return ExamplepbSimpleMessage */ -type EchoServiceEchoBody2Opts struct { +type EchoServiceApiEchoServiceEchoBody2Opts struct { Num optional.String LineNum optional.String Lang optional.String @@ -1250,7 +1235,7 @@ type EchoServiceEchoBody2Opts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEchoBody2(ctx context.Context, id string, no ExamplepbEmbedded, localVarOptionals *EchoServiceEchoBody2Opts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEchoBody2(ctx context.Context, id string, no ExamplepbEmbedded, localVarOptionals *EchoServiceApiEchoServiceEchoBody2Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} @@ -1329,9 +1314,7 @@ func (a *EchoServiceApiService) EchoServiceEchoBody2(ctx context.Context, id str 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 { @@ -1368,10 +1351,10 @@ func (a *EchoServiceApiService) EchoServiceEchoBody2(ctx context.Context, id str return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService EchoDelete method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *EchoServiceEchoDeleteOpts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEchoDeleteOpts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - @@ -1388,7 +1371,7 @@ EchoServiceApiService EchoDelete method receives a simple message and returns it @return ExamplepbSimpleMessage */ -type EchoServiceEchoDeleteOpts struct { +type EchoServiceApiEchoServiceEchoDeleteOpts struct { Id optional.String Num optional.String LineNum optional.String @@ -1403,7 +1386,7 @@ type EchoServiceEchoDeleteOpts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEchoDelete(ctx context.Context, localVarOptionals *EchoServiceEchoDeleteOpts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEchoDelete(ctx context.Context, localVarOptionals *EchoServiceApiEchoServiceEchoDeleteOpts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} @@ -1491,9 +1474,7 @@ func (a *EchoServiceApiService) EchoServiceEchoDelete(ctx context.Context, local 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 { @@ -1530,7 +1511,7 @@ func (a *EchoServiceApiService) EchoServiceEchoDelete(ctx context.Context, local return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService EchoPatch method receives a NonStandardUpdateRequest and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body @@ -1591,9 +1572,7 @@ func (a *EchoServiceApiService) EchoServiceEchoPatch(ctx context.Context, body E 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 { @@ -1630,10 +1609,10 @@ func (a *EchoServiceApiService) EchoServiceEchoPatch(ctx context.Context, body E return localVarReturnValue, localVarHttpResponse, nil } -/* +/* EchoServiceApiService EchoUnauthorized method receives a simple message and returns it. It must always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code of 401. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param optional nil or *EchoServiceEchoUnauthorizedOpts - Optional Parameters: + * @param optional nil or *EchoServiceApiEchoServiceEchoUnauthorizedOpts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - @@ -1650,7 +1629,7 @@ EchoServiceApiService EchoUnauthorized method receives a simple message and retu @return ExamplepbSimpleMessage */ -type EchoServiceEchoUnauthorizedOpts struct { +type EchoServiceApiEchoServiceEchoUnauthorizedOpts struct { Id optional.String Num optional.String LineNum optional.String @@ -1665,7 +1644,7 @@ type EchoServiceEchoUnauthorizedOpts struct { NIdVal optional.String } -func (a *EchoServiceApiService) EchoServiceEchoUnauthorized(ctx context.Context, localVarOptionals *EchoServiceEchoUnauthorizedOpts) (ExamplepbSimpleMessage, *http.Response, error) { +func (a *EchoServiceApiService) EchoServiceEchoUnauthorized(ctx context.Context, localVarOptionals *EchoServiceApiEchoServiceEchoUnauthorizedOpts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -1753,9 +1732,7 @@ func (a *EchoServiceApiService) EchoServiceEchoUnauthorized(ctx context.Context, 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 { @@ -1791,3 +1768,4 @@ func (a *EchoServiceApiService) EchoServiceEchoUnauthorized(ctx context.Context, return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/echo/client.go b/examples/internal/clients/echo/client.go index d0e2045800c..0cd38eb1ce7 100644 --- a/examples/internal/clients/echo/client.go +++ b/examples/internal/clients/echo/client.go @@ -33,8 +33,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 Echo Service API vversion not set @@ -181,7 +181,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.") } @@ -220,6 +220,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 { @@ -461,4 +471,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/examples/internal/clients/echo/model_examplepb_dynamic_message.go b/examples/internal/clients/echo/model_examplepb_dynamic_message.go index dae5858f199..ca1ce728781 100644 --- a/examples/internal/clients/echo/model_examplepb_dynamic_message.go +++ b/examples/internal/clients/echo/model_examplepb_dynamic_message.go @@ -11,6 +11,6 @@ package echo // DynamicMessage represents a message which can have its structure built dynamically using Struct and Values. type ExamplepbDynamicMessage struct { - StructField *interface{} `json:"structField,omitempty"` - ValueField *interface{} `json:"valueField,omitempty"` + StructField interface{} `json:"structField,omitempty"` + ValueField interface{} `json:"valueField,omitempty"` } diff --git a/examples/internal/clients/generateunboundmethods/.swagger-codegen/VERSION b/examples/internal/clients/generateunboundmethods/.swagger-codegen/VERSION index 752a79ef362..a932b445646 100644 --- a/examples/internal/clients/generateunboundmethods/.swagger-codegen/VERSION +++ b/examples/internal/clients/generateunboundmethods/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8 \ No newline at end of file +2.4.47-SNAPSHOT \ No newline at end of file diff --git a/examples/internal/clients/generateunboundmethods/api/swagger.yaml b/examples/internal/clients/generateunboundmethods/api/swagger.yaml index 746556eff27..f009353d62a 100644 --- a/examples/internal/clients/generateunboundmethods/api/swagger.yaml +++ b/examples/internal/clients/generateunboundmethods/api/swagger.yaml @@ -30,7 +30,7 @@ paths: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" @@ -54,7 +54,7 @@ paths: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" @@ -78,7 +78,7 @@ paths: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" diff --git a/examples/internal/clients/generateunboundmethods/api_generate_unbound_methods_echo_service.go b/examples/internal/clients/generateunboundmethods/api_generate_unbound_methods_echo_service.go index dd9c050b931..42c4d6c56be 100644 --- a/examples/internal/clients/generateunboundmethods/api_generate_unbound_methods_echo_service.go +++ b/examples/internal/clients/generateunboundmethods/api_generate_unbound_methods_echo_service.go @@ -1,3 +1,4 @@ + /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * @@ -24,7 +25,7 @@ var ( type GenerateUnboundMethodsEchoServiceApiService service -/* +/* GenerateUnboundMethodsEchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -86,9 +87,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho 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 { @@ -125,7 +124,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho return localVarReturnValue, localVarHttpResponse, nil } -/* +/* GenerateUnboundMethodsEchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. @@ -186,9 +185,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho 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 { @@ -225,7 +222,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho return localVarReturnValue, localVarHttpResponse, nil } -/* +/* GenerateUnboundMethodsEchoServiceApiService EchoDelete method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. @@ -286,9 +283,7 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho 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 { @@ -324,3 +319,4 @@ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEcho return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/generateunboundmethods/client.go b/examples/internal/clients/generateunboundmethods/client.go index 1c8138048ea..216efec3f13 100644 --- a/examples/internal/clients/generateunboundmethods/client.go +++ b/examples/internal/clients/generateunboundmethods/client.go @@ -33,8 +33,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 examples/internal/proto/examplepb/generate_unbound_methods.proto API vversion not set @@ -181,7 +181,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.") } @@ -220,6 +220,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 { @@ -461,4 +471,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/examples/internal/clients/responsebody/.swagger-codegen/VERSION b/examples/internal/clients/responsebody/.swagger-codegen/VERSION index 752a79ef362..a932b445646 100644 --- a/examples/internal/clients/responsebody/.swagger-codegen/VERSION +++ b/examples/internal/clients/responsebody/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8 \ No newline at end of file +2.4.47-SNAPSHOT \ No newline at end of file diff --git a/examples/internal/clients/responsebody/api/swagger.yaml b/examples/internal/clients/responsebody/api/swagger.yaml index 42d16be2310..cc601983ad9 100644 --- a/examples/internal/clients/responsebody/api/swagger.yaml +++ b/examples/internal/clients/responsebody/api/swagger.yaml @@ -22,7 +22,7 @@ paths: type: "string" x-exportParamName: "Data" responses: - 200: + "200": description: "" schema: type: "array" @@ -44,7 +44,7 @@ paths: type: "string" x-exportParamName: "Data" responses: - 200: + "200": description: "" schema: type: "string" @@ -64,16 +64,10 @@ paths: type: "string" x-exportParamName: "Data" responses: - 200: + "200": description: "(streaming responses)" schema: - type: "object" - properties: - result: - $ref: "#/definitions/examplepbResponseBodyOutResponse" - error: - $ref: "#/definitions/rpcStatus" - title: "Stream result of examplepbResponseBodyOut" + $ref: "#/definitions/Stream result of examplepbResponseBodyOut" default: description: "An unexpected error response." schema: @@ -90,7 +84,7 @@ paths: type: "string" x-exportParamName: "Data" responses: - 200: + "200": description: "" schema: $ref: "#/definitions/examplepbResponseBodyOutResponse" @@ -110,7 +104,7 @@ paths: type: "string" x-exportParamName: "Data" responses: - 200: + "200": description: "" schema: type: "array" @@ -259,6 +253,7 @@ definitions: - '@type': "@type" message: "message" Stream result of examplepbResponseBodyOut: + type: "object" properties: result: $ref: "#/definitions/examplepbResponseBodyOutResponse" diff --git a/examples/internal/clients/responsebody/api_response_body_service.go b/examples/internal/clients/responsebody/api_response_body_service.go index 6119c3c6567..f403b1a23ed 100644 --- a/examples/internal/clients/responsebody/api_response_body_service.go +++ b/examples/internal/clients/responsebody/api_response_body_service.go @@ -1,3 +1,4 @@ + /* * examples/internal/proto/examplepb/response_body_service.proto * @@ -25,7 +26,7 @@ var ( type ResponseBodyServiceApiService service -/* +/* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @@ -85,9 +86,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBody(ctx c 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 { @@ -124,7 +123,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBody(ctx c return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @@ -184,9 +183,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBodySameNa 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 { @@ -223,7 +220,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBodySameNa return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @@ -283,9 +280,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBodyStream 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 { @@ -322,7 +317,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBodyStream return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @@ -382,9 +377,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceListResponseBodies(ct 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 { @@ -421,7 +414,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceListResponseBodies(ct return localVarReturnValue, localVarHttpResponse, nil } -/* +/* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @@ -481,9 +474,7 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceListResponseStrings(c 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 { @@ -519,3 +510,4 @@ func (a *ResponseBodyServiceApiService) ResponseBodyServiceListResponseStrings(c return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/responsebody/client.go b/examples/internal/clients/responsebody/client.go index dfe97e57135..96625f03733 100644 --- a/examples/internal/clients/responsebody/client.go +++ b/examples/internal/clients/responsebody/client.go @@ -33,8 +33,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 examples/internal/proto/examplepb/response_body_service.proto API vversion not set @@ -181,7 +181,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.") } @@ -220,6 +220,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 { @@ -461,4 +471,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/examples/internal/clients/unannotatedecho/.swagger-codegen/VERSION b/examples/internal/clients/unannotatedecho/.swagger-codegen/VERSION index 752a79ef362..a932b445646 100644 --- a/examples/internal/clients/unannotatedecho/.swagger-codegen/VERSION +++ b/examples/internal/clients/unannotatedecho/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8 \ No newline at end of file +2.4.47-SNAPSHOT \ No newline at end of file diff --git a/examples/internal/clients/unannotatedecho/api/swagger.yaml b/examples/internal/clients/unannotatedecho/api/swagger.yaml index c7a2eb8a76b..58201325f08 100644 --- a/examples/internal/clients/unannotatedecho/api/swagger.yaml +++ b/examples/internal/clients/unannotatedecho/api/swagger.yaml @@ -137,24 +137,27 @@ paths: type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" responses: - 200: + "200": description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" - 503: + "503": description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 @@ -162,9 +165,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - externalDocs: - description: "Find out more Echo" - url: "https://github.com/grpc-ecosystem/grpc-gateway" /v1/example/echo/{id}/{num}: get: tags: @@ -257,24 +257,27 @@ paths: type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" + externalDocs: + description: "Find out more Echo" + url: "https://github.com/grpc-ecosystem/grpc-gateway" responses: - 200: + "200": description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" - 503: + "503": description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 @@ -282,9 +285,6 @@ paths: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" - externalDocs: - description: "Find out more Echo" - url: "https://github.com/grpc-ecosystem/grpc-gateway" /v1/example/echo_body: post: tags: @@ -300,15 +300,15 @@ paths: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" @@ -410,15 +410,15 @@ paths: x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: - 200: + "200": description: "A successful response." schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" @@ -442,15 +442,15 @@ paths: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" x-exportParamName: "Body" responses: - 200: + "200": description: "" schema: $ref: "#/definitions/examplepbUnannotatedNestedMessage" - 403: + "403": description: "Returned when the user does not have permission to access\ \ the resource." schema: {} - 404: + "404": description: "Returned when the resource does not exist." schema: type: "string" diff --git a/examples/internal/clients/unannotatedecho/api_unannotated_echo_service.go b/examples/internal/clients/unannotatedecho/api_unannotated_echo_service.go index 17fb7804367..6f783de95ea 100644 --- a/examples/internal/clients/unannotatedecho/api_unannotated_echo_service.go +++ b/examples/internal/clients/unannotatedecho/api_unannotated_echo_service.go @@ -1,3 +1,4 @@ + /* * Unannotated Echo * @@ -27,13 +28,13 @@ var ( type UnannotatedEchoServiceApiService service -/* +/* UnannotatedEchoServiceApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num Int value field - * @param optional nil or *UnannotatedEchoServiceEchoOpts - Optional Parameters: + * @param optional nil or *UnannotatedEchoServiceApiUnannotatedEchoServiceEchoOpts - Optional Parameters: * @param "Duration" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - @@ -49,7 +50,7 @@ Description Echo @return ExamplepbUnannotatedSimpleMessage */ -type UnannotatedEchoServiceEchoOpts struct { +type UnannotatedEchoServiceApiUnannotatedEchoServiceEchoOpts struct { Duration optional.String LineNum optional.String Lang optional.String @@ -63,7 +64,7 @@ type UnannotatedEchoServiceEchoOpts struct { NIdVal optional.String } -func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho(ctx context.Context, id string, num string, localVarOptionals *UnannotatedEchoServiceEchoOpts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { +func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho(ctx context.Context, id string, num string, localVarOptionals *UnannotatedEchoServiceApiUnannotatedEchoServiceEchoOpts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -163,9 +164,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho(ctx contex 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 { @@ -235,13 +234,13 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho(ctx contex return localVarReturnValue, localVarHttpResponse, nil } -/* +/* UnannotatedEchoServiceApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num Int value field - * @param optional nil or *UnannotatedEchoServiceEcho2Opts - Optional Parameters: + * @param optional nil or *UnannotatedEchoServiceApiUnannotatedEchoServiceEcho2Opts - Optional Parameters: * @param "Duration" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - @@ -257,7 +256,7 @@ Description Echo @return ExamplepbUnannotatedSimpleMessage */ -type UnannotatedEchoServiceEcho2Opts struct { +type UnannotatedEchoServiceApiUnannotatedEchoServiceEcho2Opts struct { Duration optional.String LineNum optional.String Lang optional.String @@ -271,7 +270,7 @@ type UnannotatedEchoServiceEcho2Opts struct { NIdVal optional.String } -func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho2(ctx context.Context, id string, num string, localVarOptionals *UnannotatedEchoServiceEcho2Opts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { +func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho2(ctx context.Context, id string, num string, localVarOptionals *UnannotatedEchoServiceApiUnannotatedEchoServiceEcho2Opts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -371,9 +370,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho2(ctx conte 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 { @@ -443,7 +440,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho2(ctx conte return localVarReturnValue, localVarHttpResponse, nil } -/* +/* UnannotatedEchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body A simple message with many types @@ -517,9 +514,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoBody(ctx co 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 { @@ -578,11 +573,11 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoBody(ctx co return localVarReturnValue, localVarHttpResponse, nil } -/* +/* UnannotatedEchoServiceApiService EchoDelete method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param num Int value field - * @param optional nil or *UnannotatedEchoServiceEchoDeleteOpts - Optional Parameters: + * @param optional nil or *UnannotatedEchoServiceApiUnannotatedEchoServiceEchoDeleteOpts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Duration" (optional.String) - * @param "LineNum" (optional.String) - @@ -599,7 +594,7 @@ UnannotatedEchoServiceApiService EchoDelete method receives a simple message and @return ExamplepbUnannotatedSimpleMessage */ -type UnannotatedEchoServiceEchoDeleteOpts struct { +type UnannotatedEchoServiceApiUnannotatedEchoServiceEchoDeleteOpts struct { Id optional.String Duration optional.String LineNum optional.String @@ -614,7 +609,7 @@ type UnannotatedEchoServiceEchoDeleteOpts struct { NIdVal optional.String } -func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoDelete(ctx context.Context, num string, localVarOptionals *UnannotatedEchoServiceEchoDeleteOpts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { +func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoDelete(ctx context.Context, num string, localVarOptionals *UnannotatedEchoServiceApiUnannotatedEchoServiceEchoDeleteOpts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} @@ -716,9 +711,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoDelete(ctx 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 { @@ -777,7 +770,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoDelete(ctx return localVarReturnValue, localVarHttpResponse, nil } -/* +/* UnannotatedEchoServiceApiService EchoNested method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body A simple message with many types @@ -851,9 +844,7 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoNested(ctx 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 { @@ -911,3 +902,4 @@ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoNested(ctx return localVarReturnValue, localVarHttpResponse, nil } + diff --git a/examples/internal/clients/unannotatedecho/client.go b/examples/internal/clients/unannotatedecho/client.go index 80ae2022984..85e6de91cb2 100644 --- a/examples/internal/clients/unannotatedecho/client.go +++ b/examples/internal/clients/unannotatedecho/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 Unannotated Echo API v1.0 @@ -182,7 +182,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.") } @@ -221,6 +221,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 { @@ -462,4 +472,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/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json b/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json index d6a1cc5ead8..675b8a795c7 100644 --- a/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json +++ b/examples/internal/proto/examplepb/a_bit_of_everything.swagger.json @@ -5070,8 +5070,7 @@ "readOnly": true } }, - "description": "The book's `name` field is used to identify the book to be updated.\nFormat: publishers/{publisher}/books/{book}", - "title": "The book to update.", + "description": "An example resource type from AIP-123 used to test the behavior described in\nthe CreateBookRequest message.\n\nSee: https://google.aip.dev/123", "required": [ "book" ] diff --git a/protoc-gen-openapiv2/internal/genopenapi/template.go b/protoc-gen-openapiv2/internal/genopenapi/template.go index 84831c28d59..58dfb76a67b 100644 --- a/protoc-gen-openapiv2/internal/genopenapi/template.go +++ b/protoc-gen-openapiv2/internal/genopenapi/template.go @@ -667,11 +667,8 @@ func renderFieldAsDefinition(f *descriptor.Field, reg *descriptor.Registry, refs return openapiSchemaObject{}, err } comments := fieldProtoComments(reg, f.Message, f) - if len(comments) > 0 { - // Use title and description from field instead of nested message if present. - paragraphs := strings.Split(comments, paragraphDeliminator) - schema.Title = strings.TrimSpace(paragraphs[0]) - schema.Description = strings.TrimSpace(strings.Join(paragraphs[1:], paragraphDeliminator)) + if err := updateOpenAPIDataFromComments(reg, &schema, f, comments, false); err != nil { + return openapiSchemaObject{}, err } // to handle case where path param is present inside the field of descriptorpb.FieldDescriptorProto_TYPE_MESSAGE type