From e6182aed21f215750b1f9089f92834c22bd0e876 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 30 Dec 2025 14:16:01 +0800 Subject: [PATCH 1/2] update go samples with more tests --- ...odels-for-testing-with-http-signature.yaml | 39 +++++ .../go/go-petstore/.openapi-generator/FILES | 2 + .../client/petstore/go/go-petstore/README.md | 2 + .../petstore/go/go-petstore/api/openapi.yaml | 51 ++++++ .../petstore/go/go-petstore/api_fake.go | 162 +++++++++++++++++- .../go/go-petstore/docs/ExampleEnum.md | 13 ++ .../petstore/go/go-petstore/docs/FakeAPI.md | 69 ++++++++ .../go/go-petstore/model_example_enum.go | 111 ++++++++++++ 8 files changed, 448 insertions(+), 1 deletion(-) create mode 100644 samples/openapi3/client/petstore/go/go-petstore/docs/ExampleEnum.md create mode 100644 samples/openapi3/client/petstore/go/go-petstore/model_example_enum.go diff --git a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index a7d9bf4139b3..0b49cbf63855 100644 --- a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -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' @@ -2306,3 +2340,8 @@ components: - type: array items: type: string + ExampleEnum: + type: string + enum: + - example1 + - example2 diff --git a/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator/FILES b/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator/FILES index f10cb891f5b8..d99a0b27da10 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator/FILES @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/go/go-petstore/README.md b/samples/openapi3/client/petstore/go/go-petstore/README.md index b8815e0b6c77..b835ca0e2c49 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/README.md +++ b/samples/openapi3/client/petstore/go/go-petstore/README.md @@ -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 | @@ -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) diff --git a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml index c07c000f2c09..ea42fcc918e1 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml +++ b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml @@ -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: @@ -2286,6 +2332,11 @@ components: - items: type: string type: array + ExampleEnum: + enum: + - example1 + - example2 + type: string _foo_get_default_response: example: string: diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go index 063323ff0824..ccb748d9e01d 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go @@ -16,9 +16,9 @@ import ( "io" "net/http" "net/url" + "reflect" "os" "time" - "reflect" ) @@ -103,6 +103,17 @@ type FakeAPI interface { // GetParameterNameMappingExecute executes the request GetParameterNameMappingExecute(r ApiGetParameterNameMappingRequest) (*http.Response, error) + /* + QueryArrayWithDefaultValues to test query array with default values + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiQueryArrayWithDefaultValuesRequest + */ + QueryArrayWithDefaultValues(ctx context.Context) ApiQueryArrayWithDefaultValuesRequest + + // QueryArrayWithDefaultValuesExecute executes the request + QueryArrayWithDefaultValuesExecute(r ApiQueryArrayWithDefaultValuesRequest) (*http.Response, error) + /* TestAdditionalPropertiesReference test referenced additionalProperties @@ -961,6 +972,155 @@ func (a *FakeAPIService) GetParameterNameMappingExecute(r ApiGetParameterNameMap return localVarHTTPResponse, nil } +type ApiQueryArrayWithDefaultValuesRequest struct { + ctx context.Context + ApiService FakeAPI + arrayparam *[]string + enumarrayparam *[]ExampleEnum + stringparam *string + body *string +} + +func (r ApiQueryArrayWithDefaultValuesRequest) Arrayparam(arrayparam []string) ApiQueryArrayWithDefaultValuesRequest { + r.arrayparam = &arrayparam + return r +} + +func (r ApiQueryArrayWithDefaultValuesRequest) Enumarrayparam(enumarrayparam []ExampleEnum) ApiQueryArrayWithDefaultValuesRequest { + r.enumarrayparam = &enumarrayparam + return r +} + +func (r ApiQueryArrayWithDefaultValuesRequest) Stringparam(stringparam string) ApiQueryArrayWithDefaultValuesRequest { + r.stringparam = &stringparam + return r +} + +func (r ApiQueryArrayWithDefaultValuesRequest) Body(body string) ApiQueryArrayWithDefaultValuesRequest { + r.body = &body + return r +} + +func (r ApiQueryArrayWithDefaultValuesRequest) Execute() (*http.Response, error) { + return r.ApiService.QueryArrayWithDefaultValuesExecute(r) +} + +/* +QueryArrayWithDefaultValues to test query array with default values + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiQueryArrayWithDefaultValuesRequest +*/ +func (a *FakeAPIService) QueryArrayWithDefaultValues(ctx context.Context) ApiQueryArrayWithDefaultValuesRequest { + return ApiQueryArrayWithDefaultValuesRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +func (a *FakeAPIService) QueryArrayWithDefaultValuesExecute(r ApiQueryArrayWithDefaultValuesRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FakeAPIService.QueryArrayWithDefaultValues") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/fake/query-array-with-default-values" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.arrayparam != nil { + t := *r.arrayparam + if reflect.TypeOf(t).Kind() == reflect.Slice { + s := reflect.ValueOf(t) + for i := 0; i < s.Len(); i++ { + parameterAddToHeaderOrQuery(localVarQueryParams, "arrayparam", s.Index(i).Interface(), "form", "multi") + } + } else { + parameterAddToHeaderOrQuery(localVarQueryParams, "arrayparam", t, "form", "multi") + } + } else { + var defaultValue []string = []string{"test1", "test2"} + parameterAddToHeaderOrQuery(localVarQueryParams, "arrayparam", defaultValue, "form", "multi") + r.arrayparam = &defaultValue + } + if r.enumarrayparam != nil { + t := *r.enumarrayparam + if reflect.TypeOf(t).Kind() == reflect.Slice { + s := reflect.ValueOf(t) + for i := 0; i < s.Len(); i++ { + parameterAddToHeaderOrQuery(localVarQueryParams, "enumarrayparam", s.Index(i).Interface(), "form", "multi") + } + } else { + parameterAddToHeaderOrQuery(localVarQueryParams, "enumarrayparam", t, "form", "multi") + } + } else { + var defaultValue []ExampleEnum = []ExampleEnum{"example1"} + parameterAddToHeaderOrQuery(localVarQueryParams, "enumarrayparam", defaultValue, "form", "multi") + r.enumarrayparam = &defaultValue + } + if r.stringparam != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "stringparam", r.stringparam, "form", "") + } else { + var defaultValue string = "test3" + parameterAddToHeaderOrQuery(localVarQueryParams, "stringparam", defaultValue, "form", "") + r.stringparam = &defaultValue + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + type ApiTestAdditionalPropertiesReferenceRequest struct { ctx context.Context ApiService FakeAPI diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/ExampleEnum.md b/samples/openapi3/client/petstore/go/go-petstore/docs/ExampleEnum.md new file mode 100644 index 000000000000..a32abfd0b36b --- /dev/null +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/ExampleEnum.md @@ -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) + + diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md index fb380f21673d..15e035fc09a5 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md @@ -10,6 +10,7 @@ Method | HTTP request | Description [**FakeOuterNumberSerialize**](FakeAPI.md#FakeOuterNumberSerialize) | **Post** /fake/outer/number | [**FakeOuterStringSerialize**](FakeAPI.md#FakeOuterStringSerialize) | **Post** /fake/outer/string | [**GetParameterNameMapping**](FakeAPI.md#GetParameterNameMapping) | **Get** /fake/parameter-name-mapping | parameter name mapping test +[**QueryArrayWithDefaultValues**](FakeAPI.md#QueryArrayWithDefaultValues) | **Post** /fake/query-array-with-default-values | to test query array with default values [**TestAdditionalPropertiesReference**](FakeAPI.md#TestAdditionalPropertiesReference) | **Post** /fake/additionalProperties-reference | test referenced additionalProperties [**TestBodyWithFileSchema**](FakeAPI.md#TestBodyWithFileSchema) | **Put** /fake/body-with-file-schema | [**TestBodyWithQueryParams**](FakeAPI.md#TestBodyWithQueryParams) | **Put** /fake/body-with-query-params | @@ -419,6 +420,74 @@ No authorization required [[Back to README]](../README.md) +## QueryArrayWithDefaultValues + +> QueryArrayWithDefaultValues(ctx).Arrayparam(arrayparam).Enumarrayparam(enumarrayparam).Stringparam(stringparam).Body(body).Execute() + +to test query array with default values + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + arrayparam := []string{"Inner_example"} // []string | (optional) (default to {"test1", "test2"}) + enumarrayparam := []openapiclient.ExampleEnum{openapiclient.ExampleEnum("example1")} // []ExampleEnum | (optional) (default to {"example1"}) + stringparam := "stringparam_example" // string | (optional) (default to "test3") + body := "body_example" // string | (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + r, err := apiClient.FakeAPI.QueryArrayWithDefaultValues(context.Background()).Arrayparam(arrayparam).Enumarrayparam(enumarrayparam).Stringparam(stringparam).Body(body).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FakeAPI.QueryArrayWithDefaultValues``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiQueryArrayWithDefaultValuesRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **arrayparam** | **[]string** | | [default to {"test1", "test2"}] + **enumarrayparam** | [**[]ExampleEnum**](ExampleEnum.md) | | [default to {"example1"}] + **stringparam** | **string** | | [default to "test3"] + **body** | **string** | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## TestAdditionalPropertiesReference > TestAdditionalPropertiesReference(ctx).RequestBody(requestBody).Execute() diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_example_enum.go b/samples/openapi3/client/petstore/go/go-petstore/model_example_enum.go new file mode 100644 index 000000000000..d7338e46222a --- /dev/null +++ b/samples/openapi3/client/petstore/go/go-petstore/model_example_enum.go @@ -0,0 +1,111 @@ +/* +OpenAPI 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 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package petstore + +import ( + "encoding/json" + "fmt" +) + +// ExampleEnum the model 'ExampleEnum' +type ExampleEnum string + +// List of ExampleEnum +const ( + EXAMPLEENUM_EXAMPLE1 ExampleEnum = "example1" + EXAMPLEENUM_EXAMPLE2 ExampleEnum = "example2" +) + +// All allowed values of ExampleEnum enum +var AllowedExampleEnumEnumValues = []ExampleEnum{ + "example1", + "example2", +} + +func (v *ExampleEnum) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := ExampleEnum(value) + for _, existing := range AllowedExampleEnumEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid ExampleEnum", value) +} + +// NewExampleEnumFromValue returns a pointer to a valid ExampleEnum +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewExampleEnumFromValue(v string) (*ExampleEnum, error) { + ev := ExampleEnum(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for ExampleEnum: valid values are %v", v, AllowedExampleEnumEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v ExampleEnum) IsValid() bool { + for _, existing := range AllowedExampleEnumEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ExampleEnum value +func (v ExampleEnum) Ptr() *ExampleEnum { + return &v +} + +type NullableExampleEnum struct { + value *ExampleEnum + isSet bool +} + +func (v NullableExampleEnum) Get() *ExampleEnum { + return v.value +} + +func (v *NullableExampleEnum) Set(val *ExampleEnum) { + v.value = val + v.isSet = true +} + +func (v NullableExampleEnum) IsSet() bool { + return v.isSet +} + +func (v *NullableExampleEnum) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableExampleEnum(val *ExampleEnum) *NullableExampleEnum { + return &NullableExampleEnum{value: val, isSet: true} +} + +func (v NullableExampleEnum) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableExampleEnum) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + From e9abb853747ea4989284348d6cd929ed21ff79b2 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 30 Dec 2025 14:23:05 +0800 Subject: [PATCH 2/2] fix indention --- .../src/main/resources/go/api.mustache | 20 ++++++++-------- .../petstore/go/go-petstore/api_fake.go | 6 ++--- .../petstore/go/go-petstore/api_fake.go | 24 +++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache index f2d06ae4a05b..2be5011b6546 100644 --- a/modules/openapi-generator/src/main/resources/go/api.mustache +++ b/modules/openapi-generator/src/main/resources/go/api.mustache @@ -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}} diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go index 48de6702cee6..da7691e1a680 100644 --- a/samples/client/petstore/go/go-petstore/api_fake.go +++ b/samples/client/petstore/go/go-petstore/api_fake.go @@ -1425,9 +1425,9 @@ func (a *FakeAPIService) TestEnumParametersExecute(r ApiTestEnumParametersReques if r.enumQueryString != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "", "") } else { - var defaultValue string = "-efg" - parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_string", defaultValue, "", "") - r.enumQueryString = &defaultValue + var defaultValue string = "-efg" + parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_string", defaultValue, "", "") + r.enumQueryString = &defaultValue } if r.enumQueryInteger != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "", "") diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go index ccb748d9e01d..27c46f2328d3 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go @@ -1048,9 +1048,9 @@ func (a *FakeAPIService) QueryArrayWithDefaultValuesExecute(r ApiQueryArrayWithD parameterAddToHeaderOrQuery(localVarQueryParams, "arrayparam", t, "form", "multi") } } else { - var defaultValue []string = []string{"test1", "test2"} - parameterAddToHeaderOrQuery(localVarQueryParams, "arrayparam", defaultValue, "form", "multi") - r.arrayparam = &defaultValue + var defaultValue []string = []string{"test1", "test2"} + parameterAddToHeaderOrQuery(localVarQueryParams, "arrayparam", defaultValue, "form", "multi") + r.arrayparam = &defaultValue } if r.enumarrayparam != nil { t := *r.enumarrayparam @@ -1063,16 +1063,16 @@ func (a *FakeAPIService) QueryArrayWithDefaultValuesExecute(r ApiQueryArrayWithD parameterAddToHeaderOrQuery(localVarQueryParams, "enumarrayparam", t, "form", "multi") } } else { - var defaultValue []ExampleEnum = []ExampleEnum{"example1"} - parameterAddToHeaderOrQuery(localVarQueryParams, "enumarrayparam", defaultValue, "form", "multi") - r.enumarrayparam = &defaultValue + var defaultValue []ExampleEnum = []ExampleEnum{"example1"} + parameterAddToHeaderOrQuery(localVarQueryParams, "enumarrayparam", defaultValue, "form", "multi") + r.enumarrayparam = &defaultValue } if r.stringparam != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "stringparam", r.stringparam, "form", "") } else { - var defaultValue string = "test3" - parameterAddToHeaderOrQuery(localVarQueryParams, "stringparam", defaultValue, "form", "") - r.stringparam = &defaultValue + var defaultValue string = "test3" + parameterAddToHeaderOrQuery(localVarQueryParams, "stringparam", defaultValue, "form", "") + r.stringparam = &defaultValue } // to determine the Content-Type header localVarHTTPContentTypes := []string{"application/json"} @@ -1911,9 +1911,9 @@ func (a *FakeAPIService) TestEnumParametersExecute(r ApiTestEnumParametersReques if r.enumQueryString != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_string", r.enumQueryString, "form", "") } else { - var defaultValue string = "-efg" - parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_string", defaultValue, "form", "") - r.enumQueryString = &defaultValue + var defaultValue string = "-efg" + parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_string", defaultValue, "form", "") + r.enumQueryString = &defaultValue } if r.enumQueryInteger != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "enum_query_integer", r.enumQueryInteger, "form", "")