fixing an issue where serverPort from additional-properties is interpreted as a string... causing the default to always be used (#4764)

This commit is contained in:
patrickcisco 2019-12-10 22:04:15 -08:00 committed by William Cheng
parent 9754ef4f88
commit 21ad2869b1

View File

@ -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 {