From b689f1a4cd554954f169a961dc70ed4fc695f9a5 Mon Sep 17 00:00:00 2001 From: weiyang Date: Fri, 29 Jun 2018 10:55:52 +0800 Subject: [PATCH] [go][api] Fix error: 'undeclared name: localVarFile' Signed-off-by: weiyang --- .../openapi-generator/src/main/resources/go/api.mustache | 7 +++++-- .../petstore/go/go-petstore/.openapi-generator/VERSION | 2 +- samples/client/petstore/go/go-petstore/docs/MapTest.md | 2 +- samples/client/petstore/go/go-petstore/model_map_test.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache index 286bedb7569c..10b7b8eb269f 100644 --- a/modules/openapi-generator/src/main/resources/go/api.mustache +++ b/modules/openapi-generator/src/main/resources/go/api.mustache @@ -177,8 +177,8 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{#hasFormParams}} {{#formParams}} {{#isFile}} -{{^required}} var localVarFile {{dataType}} +{{^required}} if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { localVarFileOk := false localVarFile, localVarFileOk = localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value().({{dataType}}) @@ -186,6 +186,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} should be {{dataType}}") } } +{{/required}} +{{#required}} + localVarFile = {{paramName}} {{/required}} if localVarFile != nil { fbs, _ := ioutil.ReadAll(localVarFile) @@ -298,4 +301,4 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil } {{/operation}} -{{/operations}} \ No newline at end of file +{{/operations}} diff --git a/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION b/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION index 82602aa4190d..0628777500bd 100644 --- a/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.3-SNAPSHOT \ No newline at end of file +3.1.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/docs/MapTest.md b/samples/client/petstore/go/go-petstore/docs/MapTest.md index 4f2b9a39b094..fc266d17df9d 100644 --- a/samples/client/petstore/go/go-petstore/docs/MapTest.md +++ b/samples/client/petstore/go/go-petstore/docs/MapTest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes **MapMapOfString** | [**map[string]map[string]string**](map.md) | | [optional] **MapOfEnumString** | **map[string]string** | | [optional] **DirectMap** | **map[string]bool** | | [optional] -**IndirectMap** | [***StringBooleanMap**](StringBooleanMap.md) | | [optional] +**IndirectMap** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional] [[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_map_test.go b/samples/client/petstore/go/go-petstore/model_map_test.go index c5cd01d5a1d6..d0c3a6a19ff3 100644 --- a/samples/client/petstore/go/go-petstore/model_map_test.go +++ b/samples/client/petstore/go/go-petstore/model_map_test.go @@ -13,5 +13,5 @@ type MapTest struct { MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty"` MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty"` DirectMap map[string]bool `json:"direct_map,omitempty"` - IndirectMap *StringBooleanMap `json:"indirect_map,omitempty"` + IndirectMap StringBooleanMap `json:"indirect_map,omitempty"` }