From 99718f98b936995d0f721ddee8297216357e194a Mon Sep 17 00:00:00 2001 From: sunn Date: Thu, 21 Jun 2018 20:08:08 +0200 Subject: [PATCH 1/3] Fix Null pointer exception in toVarName --- .../openapitools/codegen/languages/AbstractGoCodegen.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java index a3c09824a81b..ac3a5b2f50ad 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java @@ -144,8 +144,12 @@ public String escapeReservedWord(String name) { @Override public String toVarName(String name) { + + if(name != null) { + name = name.replaceAll("-", "_"); + } // replace - with _ e.g. created-at => created_at - name = sanitizeName(name.replaceAll("-", "_")); + name = sanitizeName(name); // if it's all uppper case, do nothing if (name.matches("^[A-Z_]*$")) From c3a88c519cdc6f830abef9cb6dfaae65673e4114 Mon Sep 17 00:00:00 2001 From: sunn Date: Mon, 2 Jul 2018 18:29:30 +0200 Subject: [PATCH 2/3] Removed redundant code handled in super --- .../org/openapitools/codegen/languages/AbstractGoCodegen.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java index ac3a5b2f50ad..84a2e1251783 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java @@ -145,9 +145,6 @@ public String escapeReservedWord(String name) { @Override public String toVarName(String name) { - if(name != null) { - name = name.replaceAll("-", "_"); - } // replace - with _ e.g. created-at => created_at name = sanitizeName(name); From 3c293dfec775598669144e01ca1129f77d50e229 Mon Sep 17 00:00:00 2001 From: sunn Date: Tue, 3 Jul 2018 01:22:08 +0200 Subject: [PATCH 3/3] Remove \t --- .../org/openapitools/codegen/languages/AbstractGoCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java index 84a2e1251783..d5aa594695f7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java @@ -144,7 +144,7 @@ public String escapeReservedWord(String name) { @Override public String toVarName(String name) { - + // replace - with _ e.g. created-at => created_at name = sanitizeName(name);