diff --git a/modules/swagger-codegen/src/main/resources/go/model.mustache b/modules/swagger-codegen/src/main/resources/go/model.mustache index 89057420bd2..b01d7fc21e2 100644 --- a/modules/swagger-codegen/src/main/resources/go/model.mustache +++ b/modules/swagger-codegen/src/main/resources/go/model.mustache @@ -11,9 +11,7 @@ type {{{classname}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{ const ( {{#allowableValues}} {{#enumVars}} - {{^-first}} - {{/-first}} - {{name}}_{{{classname}}} {{{classname}}} = "{{{value}}}" + {{name}} {{{classname}}} = {{{value}}} {{/enumVars}} {{/allowableValues}} ){{/isEnum}}{{^isEnum}}{{#description}} diff --git a/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION b/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION index 0443c4ad098..8c7754221a4 100644 --- a/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION +++ b/samples/client/petstore/go/go-petstore/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.16-SNAPSHOT \ No newline at end of file +2.4.19-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index dc14850d4b0..2637183ee36 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -63,6 +63,7 @@ Class | Method | HTTP request | Description - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) + - [Boolean](docs/Boolean.md) - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) @@ -74,6 +75,7 @@ Class | Method | HTTP request | Description - [EnumTest](docs/EnumTest.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [Ints](docs/Ints.md) - [List](docs/List.md) - [MapTest](docs/MapTest.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) @@ -82,6 +84,7 @@ Class | Method | HTTP request | Description - [ModelReturn](docs/ModelReturn.md) - [Name](docs/Name.md) - [NumberOnly](docs/NumberOnly.md) + - [Numbers](docs/Numbers.md) - [Order](docs/Order.md) - [OuterBoolean](docs/OuterBoolean.md) - [OuterComposite](docs/OuterComposite.md) diff --git a/samples/client/petstore/go/go-petstore/api/swagger.yaml b/samples/client/petstore/go/go-petstore/api/swagger.yaml index 35a55274005..7a6cb59c696 100644 --- a/samples/client/petstore/go/go-petstore/api/swagger.yaml +++ b/samples/client/petstore/go/go-petstore/api/swagger.yaml @@ -107,11 +107,11 @@ paths: type: "array" items: type: "string" - default: "available" enum: - "available" - "pending" - "sold" + default: "available" collectionFormat: "csv" x-exportParamName: "Status" responses: @@ -639,10 +639,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumFormStringArray" - name: "enum_form_string" in: "formData" @@ -663,10 +663,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumHeaderStringArray" - name: "enum_header_string" in: "header" @@ -687,10 +687,10 @@ paths: type: "array" items: type: "string" - default: "$" enum: - ">" - "$" + default: "$" x-exportParamName: "EnumQueryStringArray" - name: "enum_query_string" in: "query" @@ -1583,6 +1583,32 @@ definitions: type: "string" OuterBoolean: type: "boolean" + Boolean: + type: "boolean" + description: "True or False indicator" + enum: + - "true" + - "false" + Ints: + type: "integer" + format: "int32" + description: "True or False indicator" + enum: + - "0" + - "1" + - "2" + - "3" + - "4" + - "5" + - "6" + Numbers: + type: "number" + description: "some number" + enum: + - "7" + - "8" + - "9" + - "10" externalDocs: description: "Find out more about Swagger" url: "http://swagger.io" diff --git a/samples/client/petstore/go/go-petstore/docs/Boolean.md b/samples/client/petstore/go/go-petstore/docs/Boolean.md new file mode 100644 index 00000000000..d0b536f8086 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/docs/Boolean.md @@ -0,0 +1,9 @@ +# Boolean + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/go/go-petstore/docs/Ints.md b/samples/client/petstore/go/go-petstore/docs/Ints.md new file mode 100644 index 00000000000..78218e2a730 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/docs/Ints.md @@ -0,0 +1,9 @@ +# Ints + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/go/go-petstore/docs/Numbers.md b/samples/client/petstore/go/go-petstore/docs/Numbers.md new file mode 100644 index 00000000000..33da59af68c --- /dev/null +++ b/samples/client/petstore/go/go-petstore/docs/Numbers.md @@ -0,0 +1,9 @@ +# Numbers + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/go/go-petstore/model_boolean.go b/samples/client/petstore/go/go-petstore/model_boolean.go new file mode 100644 index 00000000000..3361f159495 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/model_boolean.go @@ -0,0 +1,19 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * API version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package petstore +// Boolean : True or False indicator +type Boolean bool + +// List of Boolean +const ( + TRUE Boolean = true + FALSE Boolean = false +) diff --git a/samples/client/petstore/go/go-petstore/model_enum_class.go b/samples/client/petstore/go/go-petstore/model_enum_class.go index ca1f2daae70..4950a03e747 100644 --- a/samples/client/petstore/go/go-petstore/model_enum_class.go +++ b/samples/client/petstore/go/go-petstore/model_enum_class.go @@ -14,7 +14,7 @@ type EnumClass string // List of EnumClass const ( - ABC_EnumClass EnumClass = "_abc" - EFG_EnumClass EnumClass = "-efg" - XYZ_EnumClass EnumClass = "(xyz)" + ABC EnumClass = "_abc" + EFG EnumClass = "-efg" + XYZ EnumClass = "(xyz)" ) diff --git a/samples/client/petstore/go/go-petstore/model_ints.go b/samples/client/petstore/go/go-petstore/model_ints.go new file mode 100644 index 00000000000..5b84b665bf8 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/model_ints.go @@ -0,0 +1,24 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * API version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package petstore +// Ints : True or False indicator +type Ints int32 + +// List of Ints +const ( + _0 Ints = 0 + _1 Ints = 1 + _2 Ints = 2 + _3 Ints = 3 + _4 Ints = 4 + _5 Ints = 5 + _6 Ints = 6 +) diff --git a/samples/client/petstore/go/go-petstore/model_numbers.go b/samples/client/petstore/go/go-petstore/model_numbers.go new file mode 100644 index 00000000000..4cf7b54cef5 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/model_numbers.go @@ -0,0 +1,21 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * API version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package petstore +// Numbers : some number +type Numbers float32 + +// List of Numbers +const ( + _7 Numbers = 7 + _8 Numbers = 8 + _9 Numbers = 9 + _10 Numbers = 10 +) diff --git a/samples/client/petstore/go/go-petstore/model_outer_enum.go b/samples/client/petstore/go/go-petstore/model_outer_enum.go index 31ce691a70a..0e724d17c5c 100644 --- a/samples/client/petstore/go/go-petstore/model_outer_enum.go +++ b/samples/client/petstore/go/go-petstore/model_outer_enum.go @@ -14,7 +14,7 @@ type OuterEnum string // List of OuterEnum const ( - PLACED_OuterEnum OuterEnum = "placed" - APPROVED_OuterEnum OuterEnum = "approved" - DELIVERED_OuterEnum OuterEnum = "delivered" + PLACED OuterEnum = "placed" + APPROVED OuterEnum = "approved" + DELIVERED OuterEnum = "delivered" ) diff --git a/samples/server/petstore/go-api-server/.swagger-codegen/VERSION b/samples/server/petstore/go-api-server/.swagger-codegen/VERSION index 6cecc1a68f3..8c7754221a4 100644 --- a/samples/server/petstore/go-api-server/.swagger-codegen/VERSION +++ b/samples/server/petstore/go-api-server/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.6-SNAPSHOT \ No newline at end of file +2.4.19-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/go-api-server/Dockerfile b/samples/server/petstore/go-api-server/Dockerfile new file mode 100644 index 00000000000..36e3f7ce2aa --- /dev/null +++ b/samples/server/petstore/go-api-server/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.10 AS build +WORKDIR /go/src +COPY go ./go +COPY main.go . + +ENV CGO_ENABLED=0 +RUN go get -d -v ./... + +RUN go build -a -installsuffix cgo -o swagger . + +FROM scratch AS runtime +COPY --from=build /go/src/swagger ./ +EXPOSE 8080/tcp +ENTRYPOINT ["./swagger"] diff --git a/samples/server/petstore/go-api-server/api/swagger.yaml b/samples/server/petstore/go-api-server/api/swagger.yaml index 14dce0c4d35..16209c7522b 100644 --- a/samples/server/petstore/go-api-server/api/swagger.yaml +++ b/samples/server/petstore/go-api-server/api/swagger.yaml @@ -53,7 +53,7 @@ paths: $ref: "#/definitions/Pet" x-exportParamName: "Body" responses: - 405: + "405": description: "Invalid input" security: - petstore_auth: @@ -80,11 +80,11 @@ paths: $ref: "#/definitions/Pet" x-exportParamName: "Body" responses: - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Pet not found" - 405: + "405": description: "Validation exception" security: - petstore_auth: @@ -116,13 +116,13 @@ paths: collectionFormat: "csv" x-exportParamName: "Status" responses: - 200: + "200": description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" - 400: + "400": description: "Invalid status value" security: - petstore_auth: @@ -150,13 +150,13 @@ paths: collectionFormat: "csv" x-exportParamName: "Tags" responses: - 200: + "200": description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" - 400: + "400": description: "Invalid tag value" security: - petstore_auth: @@ -182,13 +182,13 @@ paths: format: "int64" x-exportParamName: "PetId" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Pet" - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Pet not found" security: - api_key: [] @@ -226,7 +226,7 @@ paths: x-exportParamName: "Status" x-optionalDataType: "String" responses: - 405: + "405": description: "Invalid input" security: - petstore_auth: @@ -256,7 +256,7 @@ paths: format: "int64" x-exportParamName: "PetId" responses: - 400: + "400": description: "Invalid pet value" security: - petstore_auth: @@ -295,7 +295,7 @@ paths: type: "file" x-exportParamName: "File" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/ApiResponse" @@ -314,7 +314,7 @@ paths: - "application/json" parameters: [] responses: - 200: + "200": description: "successful operation" schema: type: "object" @@ -342,11 +342,11 @@ paths: $ref: "#/definitions/Order" x-exportParamName: "Body" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Order" - 400: + "400": description: "Invalid Order" /store/order/{orderId}: get: @@ -370,13 +370,13 @@ paths: format: "int64" x-exportParamName: "OrderId" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/Order" - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Order not found" delete: tags: @@ -396,9 +396,9 @@ paths: type: "string" x-exportParamName: "OrderId" responses: - 400: + "400": description: "Invalid ID supplied" - 404: + "404": description: "Order not found" /user: post: @@ -491,7 +491,7 @@ paths: type: "string" x-exportParamName: "Password" responses: - 200: + "200": description: "successful operation" headers: X-Rate-Limit: @@ -504,7 +504,7 @@ paths: description: "date in UTC when toekn expires" schema: type: "string" - 400: + "400": description: "Invalid username/password supplied" /user/logout: get: @@ -538,13 +538,13 @@ paths: type: "string" x-exportParamName: "Username" responses: - 200: + "200": description: "successful operation" schema: $ref: "#/definitions/User" - 400: + "400": description: "Invalid username supplied" - 404: + "404": description: "User not found" put: tags: @@ -570,9 +570,9 @@ paths: $ref: "#/definitions/User" x-exportParamName: "Body" responses: - 400: + "400": description: "Invalid user supplied" - 404: + "404": description: "User not found" delete: tags: @@ -591,9 +591,9 @@ paths: type: "string" x-exportParamName: "Username" responses: - 400: + "400": description: "Invalid username supplied" - 404: + "404": description: "User not found" securityDefinitions: petstore_auth: diff --git a/samples/server/petstore/go-api-server/go-api-server b/samples/server/petstore/go-api-server/go-api-server new file mode 100755 index 00000000000..f7a3da59626 Binary files /dev/null and b/samples/server/petstore/go-api-server/go-api-server differ