diff --git a/bin/java-petstore-jersey1.sh b/bin/java-petstore-jersey1.sh index cb6e0ea3a6b1..75a399b4766e 100755 --- a/bin/java-petstore-jersey1.sh +++ b/bin/java-petstore-jersey1.sh @@ -27,7 +27,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 --additional-properties hideGenerationTimestamp=true --library=jersey1 --additional-properties useNullForUnknownEnumValue=true $@" +ags="generate --artifact-id petstore-java-client-jersey1 -t modules/openapi-generator/src/main/resources/Java -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -o samples/client/petstore/java/jersey1 --additional-properties hideGenerationTimestamp=true --library=jersey1 $@" echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main" rm -rf samples/client/petstore/java/jersey1/src/main diff --git a/bin/java-petstore-jersey2.json b/bin/java-petstore-jersey2.json index e5d741be32a7..79ed4cbc2e12 100644 --- a/bin/java-petstore-jersey2.json +++ b/bin/java-petstore-jersey2.json @@ -1,7 +1,4 @@ { "library": "jersey2", - "artifactId": "petstore-jersey2", - "additionalProperties" : { - "useNullForUnknownEnumValue" : true - } + "artifactId": "petstore-jersey2" } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java index b9e93fbf26af..8f5c6d2b1643 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java @@ -61,7 +61,7 @@ public class CodegenModel { public Set allMandatory = new TreeSet(); // with parent's required properties public Set imports = new TreeSet(); - public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel; + public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel; public boolean hasOnlyReadOnly = true; // true if all properties are read-only public ExternalDocumentation externalDocumentation; @@ -118,6 +118,7 @@ public String toString() { .append("hasMoreModels", hasMoreModels) .append("hasEnums", hasEnums) .append("isEnum", isEnum) + .append("isNullable", isEnum) .append("hasRequired", hasRequired) .append("hasOptional", hasOptional) .append("isArrayModel", isArrayModel) @@ -138,86 +139,86 @@ public boolean equals(Object o) { CodegenModel that = (CodegenModel) o; return Objects.equals(parent, that.parent) && - Objects.equals(parentSchema, that.parentSchema) && - Objects.equals(interfaces, that.interfaces) && - Objects.equals(allParents, that.allParents) && - Objects.equals(parentModel, that.parentModel) && - Objects.equals(interfaceModels, that.interfaceModels) && - Objects.equals(name, that.name) && - Objects.equals(classname, that.classname) && - Objects.equals(title, that.title) && - Objects.equals(description, that.description) && - Objects.equals(classVarName, that.classVarName) && - Objects.equals(modelJson, that.modelJson) && - Objects.equals(dataType, that.dataType) && - Objects.equals(xmlPrefix, that.xmlPrefix) && - Objects.equals(xmlNamespace, that.xmlNamespace) && - Objects.equals(xmlName, that.xmlName) && - Objects.equals(classFilename, that.classFilename) && - Objects.equals(unescapedDescription, that.unescapedDescription) && - Objects.equals(discriminator, that.discriminator) && - Objects.equals(defaultValue, that.defaultValue) && - Objects.equals(vars, that.vars) && - Objects.equals(requiredVars, that.requiredVars) && - Objects.equals(optionalVars, that.optionalVars) && - Objects.equals(allVars, that.allVars) && - Objects.equals(allowableValues, that.allowableValues) && - Objects.equals(mandatory, that.mandatory) && - Objects.equals(allMandatory, that.allMandatory) && - Objects.equals(imports, that.imports) && - Objects.equals(hasVars, that.hasVars) && - Objects.equals(emptyVars, that.emptyVars) && - Objects.equals(hasMoreModels, that.hasMoreModels) && - Objects.equals(hasEnums, that.hasEnums) && - Objects.equals(isEnum, that.isEnum) && - Objects.equals(externalDocumentation, that.externalDocumentation) && - Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) && - Objects.equals(hasChildren, that.hasChildren) && - Objects.equals(parentVars, that.parentVars) && - Objects.equals(vendorExtensions, that.vendorExtensions); + Objects.equals(parentSchema, that.parentSchema) && + Objects.equals(interfaces, that.interfaces) && + Objects.equals(allParents, that.allParents) && + Objects.equals(parentModel, that.parentModel) && + Objects.equals(interfaceModels, that.interfaceModels) && + Objects.equals(name, that.name) && + Objects.equals(classname, that.classname) && + Objects.equals(title, that.title) && + Objects.equals(description, that.description) && + Objects.equals(classVarName, that.classVarName) && + Objects.equals(modelJson, that.modelJson) && + Objects.equals(dataType, that.dataType) && + Objects.equals(xmlPrefix, that.xmlPrefix) && + Objects.equals(xmlNamespace, that.xmlNamespace) && + Objects.equals(xmlName, that.xmlName) && + Objects.equals(classFilename, that.classFilename) && + Objects.equals(unescapedDescription, that.unescapedDescription) && + Objects.equals(discriminator, that.discriminator) && + Objects.equals(defaultValue, that.defaultValue) && + Objects.equals(vars, that.vars) && + Objects.equals(requiredVars, that.requiredVars) && + Objects.equals(optionalVars, that.optionalVars) && + Objects.equals(allVars, that.allVars) && + Objects.equals(allowableValues, that.allowableValues) && + Objects.equals(mandatory, that.mandatory) && + Objects.equals(allMandatory, that.allMandatory) && + Objects.equals(imports, that.imports) && + Objects.equals(hasVars, that.hasVars) && + Objects.equals(emptyVars, that.emptyVars) && + Objects.equals(hasMoreModels, that.hasMoreModels) && + Objects.equals(hasEnums, that.hasEnums) && + Objects.equals(isEnum, that.isEnum) && + Objects.equals(externalDocumentation, that.externalDocumentation) && + Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) && + Objects.equals(hasChildren, that.hasChildren) && + Objects.equals(parentVars, that.parentVars) && + Objects.equals(vendorExtensions, that.vendorExtensions); } @Override public int hashCode() { return Objects.hash( - parent, - parentSchema, - interfaces, - allParents, - parentModel, - interfaceModels, - name, - classname, - title, - description, - classVarName, - modelJson, - dataType, - xmlPrefix, - xmlNamespace, - xmlName, - classFilename, - unescapedDescription, - discriminator, - defaultValue, - vars, - requiredVars, - optionalVars, - allVars, - allowableValues, - mandatory, - allMandatory, - imports, - hasVars, - emptyVars, - hasMoreModels, - hasEnums, - isEnum, - externalDocumentation, - vendorExtensions, - hasOnlyReadOnly, - hasChildren, - parentVars); + parent, + parentSchema, + interfaces, + allParents, + parentModel, + interfaceModels, + name, + classname, + title, + description, + classVarName, + modelJson, + dataType, + xmlPrefix, + xmlNamespace, + xmlName, + classFilename, + unescapedDescription, + discriminator, + defaultValue, + vars, + requiredVars, + optionalVars, + allVars, + allowableValues, + mandatory, + allMandatory, + imports, + hasVars, + emptyVars, + hasMoreModels, + hasEnums, + isEnum, + externalDocumentation, + vendorExtensions, + hasOnlyReadOnly, + hasChildren, + parentVars); } public String getParent() { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index ba5c09b2fa6f..39415e2698d3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1572,7 +1572,7 @@ private String getPrimitiveType(Schema schema) { } else if (ModelUtils.isURISchema(schema)) { return "URI"; } else if (ModelUtils.isStringSchema(schema)) { - if(typeMapping.containsKey(schema.getFormat())) { + if (typeMapping.containsKey(schema.getFormat())) { // If the format matches a typeMapping (supplied with the --typeMappings flag) // then treat the format as a primitive type. // This allows the typeMapping flag to add a new custom type which can then @@ -1884,19 +1884,16 @@ public CodegenModel fromModel(String name, Schema schema) { if (ModelUtils.isMapSchema(schema)) { addAdditionPropertiesToCodeGenModel(m, schema); m.isMapModel = true; - } - else if (ModelUtils.isIntegerSchema(schema)) { // integer type + } else if (ModelUtils.isIntegerSchema(schema)) { // integer type m.isNumeric = Boolean.TRUE; if (ModelUtils.isLongSchema(schema)) { // int64/long format m.isLong = Boolean.TRUE; } else { // int32 format m.isInteger = Boolean.TRUE; } - } - else if (ModelUtils.isStringSchema(schema)) { + } else if (ModelUtils.isStringSchema(schema)) { m.isString = Boolean.TRUE; - } - else if (ModelUtils.isNumberSchema(schema)) { + } else if (ModelUtils.isNumberSchema(schema)) { m.isNumeric = Boolean.TRUE; if (ModelUtils.isFloatSchema(schema)) { // float m.isFloat = Boolean.TRUE; @@ -1907,6 +1904,10 @@ else if (ModelUtils.isNumberSchema(schema)) { } } + if (Boolean.TRUE.equals(schema.getNullable())) { + m.isNullable = Boolean.TRUE; + } + // passing null to allProperties and allRequired as there's no parent addVars(m, unaliasPropertySchema(schema.getProperties()), schema.getRequired(), null, null); } @@ -2650,7 +2651,7 @@ public CodegenOperation fromOperation(String path, if (requestBody != null) { if (getContentType(requestBody) != null && (getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") || - getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) { + getContentType(requestBody).toLowerCase(Locale.ROOT).startsWith("multipart/form-data"))) { // process form parameters formParams = fromRequestBodyToFormParameters(requestBody, imports); for (CodegenParameter cp : formParams) { @@ -3018,7 +3019,7 @@ public CodegenParameter fromParameter(Parameter parameter, Set imports) } Schema s; - if(parameter.getSchema() != null) { + if (parameter.getSchema() != null) { s = parameter.getSchema(); } else if (parameter.getContent() != null) { Content content = parameter.getContent(); @@ -4942,7 +4943,7 @@ protected void updateOption(String key, String defaultValue) { } protected void removeOption(String key) { - for(int i = 0; i < cliOptions.size(); i++) { + for (int i = 0; i < cliOptions.size(); i++) { if (key.equals(cliOptions.get(i).getOpt())) { cliOptions.remove(i); break; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 8a51194cc764..e06408c03653 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -52,7 +52,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code public static final String SUPPORT_JAVA6 = "supportJava6"; public static final String DISABLE_HTML_ESCAPING = "disableHtmlEscaping"; public static final String BOOLEAN_GETTER_PREFIX = "booleanGetterPrefix"; - public static final String USE_NULL_FOR_UNKNOWN_ENUM_VALUE = "useNullForUnknownEnumValue"; protected String dateLibrary = "threetenbp"; protected boolean supportAsync = false; @@ -86,7 +85,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code protected boolean supportJava6 = false; protected boolean disableHtmlEscaping = false; protected String booleanGetterPrefix = "get"; - protected boolean useNullForUnknownEnumValue = false; protected String parentGroupId = ""; protected String parentArtifactId = ""; protected String parentVersion = ""; @@ -220,10 +218,6 @@ public void processOpts() { this.setBooleanGetterPrefix(additionalProperties.get(BOOLEAN_GETTER_PREFIX).toString()); } additionalProperties.put(BOOLEAN_GETTER_PREFIX, booleanGetterPrefix); - if (additionalProperties.containsKey(USE_NULL_FOR_UNKNOWN_ENUM_VALUE)) { - this.setUseNullForUnknownEnumValue(Boolean.valueOf(additionalProperties.get(USE_NULL_FOR_UNKNOWN_ENUM_VALUE).toString())); - } - additionalProperties.put(USE_NULL_FOR_UNKNOWN_ENUM_VALUE, useNullForUnknownEnumValue); if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); @@ -1400,10 +1394,6 @@ public void setBooleanGetterPrefix(String booleanGetterPrefix) { this.booleanGetterPrefix = booleanGetterPrefix; } - public void setUseNullForUnknownEnumValue(boolean useNullForUnknownEnumValue) { - this.useNullForUnknownEnumValue = useNullForUnknownEnumValue; - } - @Override public String escapeQuotationMark(String input) { // remove " to avoid code injection diff --git a/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache b/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache index f9136b1a2011..9428bc70f991 100644 --- a/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache @@ -53,7 +53,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } {{#gson}} diff --git a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache index ea0656c2ddf6..614e260c97fc 100644 --- a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache @@ -44,7 +44,7 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } {{#gson}} diff --git a/modules/openapi-generator/src/main/resources/JavaInflector/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaInflector/enumClass.mustache index 2f36ba0b6c11..0fe7d8c27b54 100644 --- a/modules/openapi-generator/src/main/resources/JavaInflector/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaInflector/enumClass.mustache @@ -39,6 +39,6 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaInflector/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaInflector/enumOuterClass.mustache index 0808ffda73e1..9e032184bedd 100644 --- a/modules/openapi-generator/src/main/resources/JavaInflector/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaInflector/enumOuterClass.mustache @@ -37,6 +37,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/enumClass.mustache index dc7b2db82777..2d7d5388cf4b 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/enumClass.mustache @@ -28,6 +28,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumClass.mustache index 549a7b100c9d..34b72f9a0574 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumClass.mustache @@ -28,6 +28,6 @@ public enum {{datatypeWithEnum}} { return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumOuterClass.mustache index d807cfb17ada..86916472d2de 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext/enumOuterClass.mustache @@ -42,7 +42,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache index 10170a28a183..3e19ca980967 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache @@ -28,6 +28,6 @@ public enum {{datatypeWithEnum}} { return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache index d807cfb17ada..86916472d2de 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache @@ -42,7 +42,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/enumClass.mustache index 383b36a572ae..67c7fcc52067 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/enumClass.mustache @@ -49,6 +49,6 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/enumOuterClass.mustache index 48b9beb1a746..eb063d56c608 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/enumOuterClass.mustache @@ -47,6 +47,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/modelEnum.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/modelEnum.mustache index 33dc27b702a4..906ebdb28f41 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/modelEnum.mustache @@ -45,7 +45,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } {{/jackson}} } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache index ab47115aaef3..81284b7dd354 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache @@ -28,6 +28,6 @@ public enum {{datatypeWithEnum}} { return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumOuterClass.mustache index e6c303b1e706..2865cf70cfd9 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumOuterClass.mustache @@ -38,6 +38,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumClass.mustache index 64fd1abbc844..211fddf21f4b 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumClass.mustache @@ -39,6 +39,6 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumOuterClass.mustache index fa51217a5c11..91d3edab7b04 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/enumOuterClass.mustache @@ -37,6 +37,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/enumClass.mustache index c1ca5e39b709..2e90275477f9 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/enumClass.mustache @@ -39,6 +39,6 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/enumOuterClass.mustache index b83507092e83..60d13571cbdd 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/enumOuterClass.mustache @@ -37,6 +37,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/JavaVertXServer/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/JavaVertXServer/enumOuterClass.mustache index 97d8170d5f8d..e89caa5a3f20 100644 --- a/modules/openapi-generator/src/main/resources/JavaVertXServer/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaVertXServer/enumOuterClass.mustache @@ -31,6 +31,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/java-msf4j-server/enumClass.mustache b/modules/openapi-generator/src/main/resources/java-msf4j-server/enumClass.mustache index 2f36ba0b6c11..0fe7d8c27b54 100644 --- a/modules/openapi-generator/src/main/resources/java-msf4j-server/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/java-msf4j-server/enumClass.mustache @@ -39,6 +39,6 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/java-msf4j-server/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/java-msf4j-server/enumOuterClass.mustache index 0808ffda73e1..9e032184bedd 100644 --- a/modules/openapi-generator/src/main/resources/java-msf4j-server/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/java-msf4j-server/enumOuterClass.mustache @@ -37,6 +37,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/java-pkmst/enumClass.mustache b/modules/openapi-generator/src/main/resources/java-pkmst/enumClass.mustache index 2f36ba0b6c11..0fe7d8c27b54 100644 --- a/modules/openapi-generator/src/main/resources/java-pkmst/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/java-pkmst/enumClass.mustache @@ -39,6 +39,6 @@ return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/java-pkmst/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/java-pkmst/enumOuterClass.mustache index 0808ffda73e1..9e032184bedd 100644 --- a/modules/openapi-generator/src/main/resources/java-pkmst/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/java-pkmst/enumOuterClass.mustache @@ -37,6 +37,6 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum return b; } } - {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/main/resources/java-undertow-server/enumOuterClass.mustache b/modules/openapi-generator/src/main/resources/java-undertow-server/enumOuterClass.mustache index 3b43067c9797..5333fff8c06e 100644 --- a/modules/openapi-generator/src/main/resources/java-undertow-server/enumOuterClass.mustache +++ b/modules/openapi-generator/src/main/resources/java-undertow-server/enumOuterClass.mustache @@ -37,6 +37,6 @@ if (String.valueOf(b.value).equals(text)) { return b; } } -{{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}} +{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/isNullable}} } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java index 3db02060a1b7..4eb0a49f6904 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java @@ -113,7 +113,6 @@ public void testInitialConfigValues() throws Exception { Assert.assertEquals(codegen.getInvokerPackage(), "org.openapitools"); Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "org.openapitools"); Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.BOOLEAN_GETTER_PREFIX), "get"); - Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE), Boolean.FALSE); } @Test @@ -124,7 +123,6 @@ public void testSettersForConfigValues() throws Exception { codegen.setApiPackage("xyz.yyyyy.zzzzzzz.api"); codegen.setInvokerPackage("xyz.yyyyy.zzzzzzz.invoker"); codegen.setBooleanGetterPrefix("is"); - codegen.setUseNullForUnknownEnumValue(true); codegen.processOpts(); Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); @@ -136,7 +134,6 @@ public void testSettersForConfigValues() throws Exception { Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.invoker"); Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.zzzzzzz.invoker"); Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.BOOLEAN_GETTER_PREFIX), "is"); - Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE), Boolean.TRUE); } @Test @@ -147,7 +144,6 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception { codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.api.oooooo"); codegen.additionalProperties().put(CodegenConstants.INVOKER_PACKAGE, "xyz.yyyyy.invoker.oooooo"); codegen.additionalProperties().put(AbstractJavaCodegen.BOOLEAN_GETTER_PREFIX, "getBoolean"); - codegen.additionalProperties().put(AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE, "true"); codegen.processOpts(); Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); @@ -159,7 +155,6 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception { Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.invoker.oooooo"); Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.invoker.oooooo"); Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.BOOLEAN_GETTER_PREFIX), "getBoolean"); - Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE), Boolean.TRUE); } @Test diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSCXFExtServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSCXFExtServerCodegenTest.java index d82604870343..61081616fdec 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSCXFExtServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSCXFExtServerCodegenTest.java @@ -133,11 +133,6 @@ public boolean isUseMultipartFeature() { return useMultipartFeature; } - // AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE - public boolean isUseNullForUnknownEnumValue() { - return useNullForUnknownEnumValue; - } - // SpringFeatures.USE_SPRING_ANNOTATION_CONFIG public boolean isUseSpringAnnotationConfig() { return useSpringAnnotationConfig; @@ -253,7 +248,6 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception { additionalProperties.put(AbstractJavaCodegen.JAVA8_MODE, "true"); additionalProperties.put(AbstractJavaCodegen.SUPPORT_ASYNC, "true"); additionalProperties.put(AbstractJavaCodegen.SUPPORT_JAVA6, "false"); - additionalProperties.put(AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE, "true"); additionalProperties.put(AbstractJavaCodegen.WITH_XML, "true"); // Options processed by AbstractJavaJAXRSServerCodegen additionalProperties.put(CodegenConstants.IMPL_FOLDER, "myimpl"); @@ -328,7 +322,6 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception { assertEquals(testerCodegen.isFullJavaUtil(), true); assertEquals(testerCodegen.isJava8Mode(), true); assertEquals(testerCodegen.isSupportAsync(), true); - assertEquals(testerCodegen.isUseNullForUnknownEnumValue(), true); assertEquals(testerCodegen.isWithXml(), true); // Options processed by AbstractJavaJAXRSServerCodegen assertEquals(testerCodegen.getImplFolder(), "myimpl"); @@ -581,7 +574,6 @@ public void testInitialConfigValues() throws Exception { assertNull(additionalProperties.get(AbstractJavaCodegen.JAVA8_MODE)); assertNull(additionalProperties.get(AbstractJavaCodegen.SUPPORT_ASYNC)); assertEquals(additionalProperties.get(AbstractJavaCodegen.SUPPORT_JAVA6), Boolean.FALSE); - assertEquals(additionalProperties.get(AbstractJavaCodegen.USE_NULL_FOR_UNKNOWN_ENUM_VALUE), false); assertEquals(additionalProperties.get(AbstractJavaCodegen.WITH_XML), false); // Options processed by AbstractJavaJAXRSServerCodegen assertNull(additionalProperties.get(CodegenConstants.IMPL_FOLDER)); diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml index a8a0687c738c..42c3d46a8b83 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1580,6 +1580,7 @@ components: - fish - crab OuterEnum: + nullable: true type: string enum: - placed diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumArrays.java index e0b5a0b76049..40e31bf3caf4 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -59,7 +59,7 @@ public static JustSymbolEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } @@ -97,7 +97,7 @@ public static ArrayEnumEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumClass.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumClass.java index 5633f0280516..a4cc808868de 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumClass.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumClass.java @@ -53,7 +53,7 @@ public static EnumClass fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumTest.java index 3d5976cb9e48..d4b36798ee68 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/EnumTest.java @@ -60,7 +60,7 @@ public static EnumStringEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } @@ -100,7 +100,7 @@ public static EnumStringRequiredEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } @@ -138,7 +138,7 @@ public static EnumIntegerEnum fromValue(Integer value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } @@ -176,7 +176,7 @@ public static EnumNumberEnum fromValue(Double value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/MapTest.java index 65ab3afca0c0..a7a141bb9b3d 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/MapTest.java @@ -63,7 +63,7 @@ public static InnerEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Order.java index 18197114a2d3..9e935d606ef1 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Order.java @@ -72,7 +72,7 @@ public static StatusEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/OuterEnum.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/OuterEnum.java index f83b0c95877a..dacbbdfb2c91 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/OuterEnum.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/OuterEnum.java @@ -53,7 +53,7 @@ public static OuterEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Pet.java index 0e52f362375c..63e9b4ff5de1 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/model/Pet.java @@ -78,7 +78,7 @@ public static StatusEnum fromValue(String value) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } } diff --git a/samples/client/petstore/java/jersey2-java6/pom.xml b/samples/client/petstore/java/jersey2-java6/pom.xml index 8a80c6c15874..7f29de9bf660 100644 --- a/samples/client/petstore/java/jersey2-java6/pom.xml +++ b/samples/client/petstore/java/jersey2-java6/pom.xml @@ -210,6 +210,13 @@ ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + + org.glassfish.jersey.core diff --git a/samples/client/petstore/java/jersey2-java8/pom.xml b/samples/client/petstore/java/jersey2-java8/pom.xml index 75381cb9defd..5d62f179fe71 100644 --- a/samples/client/petstore/java/jersey2-java8/pom.xml +++ b/samples/client/petstore/java/jersey2-java8/pom.xml @@ -210,6 +210,13 @@ ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + + org.glassfish.jersey.core diff --git a/samples/client/petstore/java/resteasy/pom.xml b/samples/client/petstore/java/resteasy/pom.xml index ed8cee8d1288..1b327454a681 100644 --- a/samples/client/petstore/java/resteasy/pom.xml +++ b/samples/client/petstore/java/resteasy/pom.xml @@ -160,6 +160,12 @@ swagger-annotations ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + org.jboss.resteasy diff --git a/samples/client/petstore/java/resttemplate-withXml/pom.xml b/samples/client/petstore/java/resttemplate-withXml/pom.xml index fe4ba6cf40b3..03f37e2fc0c3 100644 --- a/samples/client/petstore/java/resttemplate-withXml/pom.xml +++ b/samples/client/petstore/java/resttemplate-withXml/pom.xml @@ -200,6 +200,13 @@ swagger-annotations ${swagger-annotations-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + diff --git a/samples/client/petstore/java/resttemplate/pom.xml b/samples/client/petstore/java/resttemplate/pom.xml index ff4d882ede7e..3f6172a6765c 100644 --- a/samples/client/petstore/java/resttemplate/pom.xml +++ b/samples/client/petstore/java/resttemplate/pom.xml @@ -200,6 +200,13 @@ swagger-annotations ${swagger-annotations-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + diff --git a/samples/client/petstore/java/retrofit/pom.xml b/samples/client/petstore/java/retrofit/pom.xml index 855a65765389..fff98c3ba385 100644 --- a/samples/client/petstore/java/retrofit/pom.xml +++ b/samples/client/petstore/java/retrofit/pom.xml @@ -200,6 +200,12 @@ swagger-annotations ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + com.squareup.retrofit retrofit diff --git a/samples/client/petstore/java/retrofit2-play24/pom.xml b/samples/client/petstore/java/retrofit2-play24/pom.xml index 1a8e8758259d..6a8a48bd5a6e 100644 --- a/samples/client/petstore/java/retrofit2-play24/pom.xml +++ b/samples/client/petstore/java/retrofit2-play24/pom.xml @@ -191,6 +191,12 @@ swagger-annotations ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + com.squareup.retrofit2 converter-gson diff --git a/samples/client/petstore/java/retrofit2-play25/pom.xml b/samples/client/petstore/java/retrofit2-play25/pom.xml index ced3973a7c07..e82fe6f2b111 100644 --- a/samples/client/petstore/java/retrofit2-play25/pom.xml +++ b/samples/client/petstore/java/retrofit2-play25/pom.xml @@ -191,6 +191,12 @@ swagger-annotations ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + com.squareup.retrofit2 converter-gson diff --git a/samples/client/petstore/java/retrofit2-play26/pom.xml b/samples/client/petstore/java/retrofit2-play26/pom.xml index 4a764c94f837..d03f83d54f9a 100644 --- a/samples/client/petstore/java/retrofit2-play26/pom.xml +++ b/samples/client/petstore/java/retrofit2-play26/pom.xml @@ -191,6 +191,12 @@ swagger-annotations ${swagger-annotations-version} + + + com.google.code.findbugs + jsr305 + 3.0.2 + com.squareup.retrofit2 converter-gson diff --git a/samples/client/petstore/java/webclient/pom.xml b/samples/client/petstore/java/webclient/pom.xml index 262a5b0b5c91..ee6480dc262e 100644 --- a/samples/client/petstore/java/webclient/pom.xml +++ b/samples/client/petstore/java/webclient/pom.xml @@ -65,6 +65,13 @@ swagger-annotations ${swagger-annotations-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + io.projectreactor diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index ec484c4519cf..07b17fe5daba 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -72,8 +72,7 @@ def __init__(self, enum_string=None, enum_string_required=None, enum_integer=Non self.enum_integer = enum_integer if enum_number is not None: self.enum_number = enum_number - if outer_enum is not None: - self.outer_enum = outer_enum + self.outer_enum = outer_enum if outer_enum_integer is not None: self.outer_enum_integer = outer_enum_integer if outer_enum_default_value is not None: diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/OuterEnum.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/OuterEnum.java index 06362e3365ec..1c1eb9c84c43 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/OuterEnum.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/OuterEnum.java @@ -55,7 +55,7 @@ public static OuterEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } } diff --git a/samples/server/petstore/kotlin-springboot-reactive/pom.xml b/samples/server/petstore/kotlin-springboot-reactive/pom.xml index c8683e54bc26..b0a954d47075 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/pom.xml +++ b/samples/server/petstore/kotlin-springboot-reactive/pom.xml @@ -96,6 +96,12 @@ swagger-annotations 1.5.21 + + + com.google.code.findbugs + jsr305 + 3.0.2 + com.fasterxml.jackson.dataformat jackson-dataformat-yaml diff --git a/samples/server/petstore/kotlin-springboot/pom.xml b/samples/server/petstore/kotlin-springboot/pom.xml index 10720393bf09..38491e8939c5 100644 --- a/samples/server/petstore/kotlin-springboot/pom.xml +++ b/samples/server/petstore/kotlin-springboot/pom.xml @@ -86,6 +86,12 @@ swagger-annotations 1.5.21 + + + com.google.code.findbugs + jsr305 + 3.0.2 + com.fasterxml.jackson.dataformat jackson-dataformat-yaml