From 21ad2869b199428fbe937ee46ec9f64308b346b2 Mon Sep 17 00:00:00 2001 From: patrickcisco Date: Tue, 10 Dec 2019 22:04:15 -0800 Subject: [PATCH] fixing an issue where serverPort from additional-properties is interpreted as a string... causing the default to always be used (#4764) --- .../codegen/languages/GoServerCodegen.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java index 211dcdadb99..e37f80bf409 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoServerCodegen.java @@ -144,10 +144,19 @@ public class GoServerCodegen extends AbstractGoCodegen { if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) { this.setServerPort((int) additionalProperties.get("serverPort")); + } else if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof String){ + try { + this.setServerPort(Integer.parseInt(additionalProperties.get("serverPort").toString())); + additionalProperties.put("serverPort", serverPort); + } + catch (NumberFormatException e) + { + LOGGER.warn("serverPort is not a valid integer... defaulting to {}", serverPort); + additionalProperties.put("serverPort", serverPort); + } } else { additionalProperties.put("serverPort", serverPort); } - if (additionalProperties.containsKey("featureCORS")) { this.setFeatureCORS(convertPropertyToBooleanAndWriteBack("featureCORS")); } else {