Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions modules/openapi-generator/src/main/resources/go/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,16 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
{{/isCollectionFormatMulti}}
{{#defaultValue}}} else {
{{#isArray}}
var defaultValue {{{dataType}}} = {{{dataType}}}{{{.}}}
parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", defaultValue, "{{style}}", "{{collectionFormat}}")
r.{{paramName}} = &defaultValue
{{/isArray}}
{{^isArray}}
var defaultValue {{{dataType}}} = {{{.}}}
parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", defaultValue, "{{style}}", "{{collectionFormat}}")
r.{{paramName}} = &defaultValue
{{/isArray}}
{{#isArray}}
var defaultValue {{{dataType}}} = {{{dataType}}}{{{.}}}
parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", defaultValue, "{{style}}", "{{collectionFormat}}")
r.{{paramName}} = &defaultValue
{{/isArray}}
{{^isArray}}
var defaultValue {{{dataType}}} = {{{.}}}
parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", defaultValue, "{{style}}", "{{collectionFormat}}")
r.{{paramName}} = &defaultValue
{{/isArray}}
{{/defaultValue}}}
{{/required}}
{{/queryParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,40 @@ paths:
application/json:
schema:
type: object
/fake/query-array-with-default-values:
post:
tags:
- fake
summary: to test query array with default values
operationId: query_array_with_default_values
requestBody:
content:
application/json:
schema:
type: string
parameters:
- name: "arrayparam"
in: query
schema:
type: array
items:
type: string
default: ["test1", "test2"]
- name: "enumarrayparam"
in: query
schema:
type: array
items:
$ref: "#/components/schemas/ExampleEnum"
default: ["example1"]
- name: "stringparam"
in: query
schema:
type: string
default: "test3"
responses:
200:
description: Ok
servers:
- url: 'http://localhost/v2'
- url: 'http://{server}.swagger.io:{port}/v2'
Expand Down Expand Up @@ -2306,3 +2340,8 @@ components:
- type: array
items:
type: string
ExampleEnum:
type: string
enum:
- example1
- example2
6 changes: 3 additions & 3 deletions samples/client/petstore/go/go-petstore/api_fake.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ docs/DuplicatedPropParent.md
docs/EnumArrays.md
docs/EnumClass.md
docs/EnumTest.md
docs/ExampleEnum.md
docs/FakeAPI.md
docs/FakeClassnameTags123API.md
docs/File.md
Expand Down Expand Up @@ -123,6 +124,7 @@ model_duplicated_prop_parent.go
model_enum_arrays.go
model_enum_class.go
model_enum_test_.go
model_example_enum.go
model_file.go
model_file_schema_test_class.go
model_filter_any.go
Expand Down
2 changes: 2 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Class | Method | HTTP request | Description
*FakeAPI* | [**FakeOuterNumberSerialize**](docs/FakeAPI.md#fakeouternumberserialize) | **Post** /fake/outer/number |
*FakeAPI* | [**FakeOuterStringSerialize**](docs/FakeAPI.md#fakeouterstringserialize) | **Post** /fake/outer/string |
*FakeAPI* | [**GetParameterNameMapping**](docs/FakeAPI.md#getparameternamemapping) | **Get** /fake/parameter-name-mapping | parameter name mapping test
*FakeAPI* | [**QueryArrayWithDefaultValues**](docs/FakeAPI.md#queryarraywithdefaultvalues) | **Post** /fake/query-array-with-default-values | to test query array with default values
*FakeAPI* | [**TestAdditionalPropertiesReference**](docs/FakeAPI.md#testadditionalpropertiesreference) | **Post** /fake/additionalProperties-reference | test referenced additionalProperties
*FakeAPI* | [**TestBodyWithFileSchema**](docs/FakeAPI.md#testbodywithfileschema) | **Put** /fake/body-with-file-schema |
*FakeAPI* | [**TestBodyWithQueryParams**](docs/FakeAPI.md#testbodywithqueryparams) | **Put** /fake/body-with-query-params |
Expand Down Expand Up @@ -154,6 +155,7 @@ Class | Method | HTTP request | Description
- [EnumArrays](docs/EnumArrays.md)
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
- [ExampleEnum](docs/ExampleEnum.md)
- [File](docs/File.md)
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
- [FilterAny](docs/FilterAny.md)
Expand Down
51 changes: 51 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,52 @@ paths:
schema:
type: object
description: success
/fake/query-array-with-default-values:
post:
operationId: query_array_with_default_values
parameters:
- explode: true
in: query
name: arrayparam
required: false
schema:
default:
- test1
- test2
items:
type: string
type: array
style: form
- explode: true
in: query
name: enumarrayparam
required: false
schema:
default:
- example1
items:
$ref: "#/components/schemas/ExampleEnum"
type: array
style: form
- explode: true
in: query
name: stringparam
required: false
schema:
default: test3
type: string
style: form
requestBody:
content:
application/json:
schema:
type: string
responses:
"200":
description: Ok
summary: to test query array with default values
tags:
- fake
components:
requestBodies:
UserArray:
Expand Down Expand Up @@ -2286,6 +2332,11 @@ components:
- items:
type: string
type: array
ExampleEnum:
enum:
- example1
- example2
type: string
_foo_get_default_response:
example:
string:
Expand Down
168 changes: 164 additions & 4 deletions samples/openapi3/client/petstore/go/go-petstore/api_fake.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ExampleEnum

## Enum


* `EXAMPLE1` (value: `"example1"`)

* `EXAMPLE2` (value: `"example2"`)


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading
Loading