From 86e53d6f0b960cc188e8d05a3b04e6561b5f034b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 6 Jun 2019 01:57:16 +0800 Subject: [PATCH] fix NPE in go generator (#3104) --- bin/utils/ensure-up-to-date | 1 + .../org/openapitools/codegen/languages/GoClientCodegen.java | 2 +- .../go/go-petstore-withXml/.openapi-generator/VERSION | 2 +- samples/client/petstore/go/go-petstore-withXml/client.go | 2 +- .../client/petstore/go/go-petstore-withXml/docs/UserApi.md | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 3d5909a88d8..8cf31ae0c51 100755 --- a/bin/utils/ensure-up-to-date +++ b/bin/utils/ensure-up-to-date @@ -51,6 +51,7 @@ declare -a scripts=( "./bin/csharp-netcore-petstore-all.sh" "./bin/elixir-petstore.sh" "./bin/go-petstore.sh" +"./bin/go-petstore-withxml.sh" "./bin/go-gin-petstore-server.sh" "./bin/groovy-petstore.sh" "./bin/apex-petstore.sh" diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java index 2ea1a2918c8..749ae845c8e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java @@ -114,7 +114,7 @@ public class GoClientCodegen extends AbstractGoCodegen { } } - if (additionalProperties.containsKey(WITH_GO_CODEGEN_COMMENT)) { + if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) { setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString())); if (isGoSubmodule) { additionalProperties.put(CodegenConstants.IS_GO_SUBMODULE, "true"); diff --git a/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION b/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION index 06b5019af3f..d96260ba335 100644 --- a/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION +++ b/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.1-SNAPSHOT \ No newline at end of file +4.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore-withXml/client.go b/samples/client/petstore/go/go-petstore-withXml/client.go index 973bad121ed..c666bcfe6ea 100644 --- a/samples/client/petstore/go/go-petstore-withXml/client.go +++ b/samples/client/petstore/go/go-petstore-withXml/client.go @@ -388,7 +388,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { - xml.NewEncoder(bodyBuf).Encode(body) + err = xml.NewEncoder(bodyBuf).Encode(body) } if err != nil { diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md index ea19e0e716f..3201e1771dc 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md @@ -59,7 +59,7 @@ Creates list of users with given input array Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**body** | [**[]User**](array.md)| List of user object | +**body** | [**[]User**](User.md)| List of user object | ### Return type @@ -90,7 +90,7 @@ Creates list of users with given input array Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**body** | [**[]User**](array.md)| List of user object | +**body** | [**[]User**](User.md)| List of user object | ### Return type