From 6e6b8472d4869148840ebaf7cfe5c72d6ed22d7b Mon Sep 17 00:00:00 2001
From: Justin Black
Date: Wed, 26 May 2021 11:59:28 -0700
Subject: [PATCH] Adds isShort + isUnboundedInteger to
IJsonSchemaValidationProperties implementers (#9519)
* Adds getter + setter methods for isShortInteger in IJsonSchemaValidationProperties
* Adds isShortInteger to CodegenModel
* Adds isShortInteger to CodegenProperty
* Adds isShortInteger to CodegenParameter
* Adds isShortInteger to CodegenResponse
* Ensures that samples are up to date
* Changes interface to isShort
* Removes typescript file
* Adds isShort to CodegenModel and CodegenProperty instances
* Samples updated, shows too many changes across generators
* Adds isUnboundedInteger and implements it in CodegenModel
* Adds isUnboundedInteger to COdegenProperty
* Adds isUnboundedInteger to CodegenParameter
* Adds isUnboundedInteger to CodegenResponse
* Regenerates samples and docs
* Adds testBooleansSetForIntSchemas
* Fixes integer tests
---
.../openapitools/codegen/CodegenModel.java | 24 +++-
.../codegen/CodegenParameter.java | 26 +++-
.../openapitools/codegen/CodegenProperty.java | 24 +++-
.../openapitools/codegen/CodegenResponse.java | 24 +++-
.../openapitools/codegen/DefaultCodegen.java | 29 ++++-
.../IJsonSchemaValidationProperties.java | 10 +-
.../codegen/DefaultCodegenTest.java | 123 ++++++++++++++++++
.../src/test/resources/3_0/issue_9447.yaml | 106 +++++++++++++++
.../handler/PathHandlerInterface.java | 4 +-
9 files changed, 356 insertions(+), 14 deletions(-)
create mode 100644 modules/openapi-generator/src/test/resources/3_0/issue_9447.yaml
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 e7a3adce6a3..7669f837919 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
@@ -64,7 +64,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public String defaultValue;
public String arrayModelType;
public boolean isAlias; // Is this effectively an alias of another simple type
- public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime;
+ public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isShort, isUnboundedInteger;
private boolean additionalPropertiesIsAnyType;
public List vars = new ArrayList(); // all properties (without parent's properties)
public List allVars = new ArrayList(); // all properties (with parent's properties)
@@ -606,6 +606,22 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.isArray = isArray;
}
+ @Override
+ public boolean getIsShort() { return isShort; }
+
+ @Override
+ public void setIsShort(boolean isShort) {
+ this.isShort = isShort;
+ }
+
+ @Override
+ public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
+
+ @Override
+ public void setIsUnboundedInteger(boolean isUnboundedInteger) {
+ this.isUnboundedInteger = isUnboundedInteger;
+ }
+
@Override
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
@@ -752,7 +768,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
return isAlias == that.isAlias &&
isString == that.isString &&
isInteger == that.isInteger &&
+ isShort == that.isShort &&
isLong == that.isLong &&
+ isUnboundedInteger == that.isUnboundedInteger &&
isNumber == that.isNumber &&
isNumeric == that.isNumeric &&
isFloat == that.isFloat &&
@@ -839,7 +857,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
getDescription(), getClassVarName(), getModelJson(), getDataType(), getXmlPrefix(), getXmlNamespace(),
getXmlName(), getClassFilename(), getUnescapedDescription(), getDiscriminator(), getDefaultValue(),
getArrayModelType(), isAlias, isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble,
- isDate, isDateTime, isNull, hasValidation,
+ isDate, isDateTime, isNull, hasValidation, isShort, isUnboundedInteger,
getVars(), getAllVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
isEmptyVars(), hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArray,
@@ -881,7 +899,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", isAlias=").append(isAlias);
sb.append(", isString=").append(isString);
sb.append(", isInteger=").append(isInteger);
+ sb.append(", isShort=").append(isShort);
sb.append(", isLong=").append(isLong);
+ sb.append(", isUnboundedInteger=").append(isUnboundedInteger);
sb.append(", isNumber=").append(isNumber);
sb.append(", isNumeric=").append(isNumeric);
sb.append(", isFloat=").append(isFloat);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
index 326785046d9..d2dc9fa9808 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
@@ -35,7 +35,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public String example; // example value (x-example)
public String jsonSchema;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
- isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType;
+ isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
public boolean isArray, isMap;
public boolean isFile;
public boolean isEnum;
@@ -184,7 +184,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
output.isString = this.isString;
output.isNumeric = this.isNumeric;
output.isInteger = this.isInteger;
+ output.isShort = this.isShort;
output.isLong = this.isLong;
+ output.isUnboundedInteger = this.isUnboundedInteger;
output.isDouble = this.isDouble;
output.isDecimal = this.isDecimal;
output.isFloat = this.isFloat;
@@ -209,7 +211,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
@Override
public int hashCode() {
- return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired);
+ return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger);
}
@Override
@@ -231,7 +233,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
isString == that.isString &&
isNumeric == that.isNumeric &&
isInteger == that.isInteger &&
+ isShort == that.isShort &&
isLong == that.isLong &&
+ isUnboundedInteger == that.isUnboundedInteger &&
isNumber == that.isNumber &&
isFloat == that.isFloat &&
isDouble == that.isDouble &&
@@ -328,7 +332,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
sb.append(", isString=").append(isString);
sb.append(", isNumeric=").append(isNumeric);
sb.append(", isInteger=").append(isInteger);
+ sb.append(", isShort=").append(isShort);
sb.append(", isLong=").append(isLong);
+ sb.append(", isUnboundedInteger=").append(isUnboundedInteger);
sb.append(", isNumber=").append(isNumber);
sb.append(", isFloat=").append(isFloat);
sb.append(", isDouble=").append(isDouble);
@@ -560,6 +566,22 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
this.isArray = isArray;
}
+ @Override
+ public boolean getIsShort() { return isShort; }
+
+ @Override
+ public void setIsShort(boolean isShort) {
+ this.isShort = isShort;
+ }
+
+ @Override
+ public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
+
+ @Override
+ public void setIsUnboundedInteger(boolean isUnboundedInteger) {
+ this.isUnboundedInteger = isUnboundedInteger;
+ }
+
@Override
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
index b20e55f61b4..47e69fe89d4 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
@@ -118,7 +118,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean isString;
public boolean isNumeric;
public boolean isInteger;
+ public boolean isShort;
public boolean isLong;
+ public boolean isUnboundedInteger;
public boolean isNumber;
public boolean isFloat;
public boolean isDouble;
@@ -507,6 +509,22 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isArray = isArray;
}
+ @Override
+ public boolean getIsShort() { return isShort; }
+
+ @Override
+ public void setIsShort(boolean isShort) {
+ this.isShort = isShort;
+ }
+
+ @Override
+ public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
+
+ @Override
+ public void setIsUnboundedInteger(boolean isUnboundedInteger) {
+ this.isUnboundedInteger = isUnboundedInteger;
+ }
+
public Map getVendorExtensions() {
return vendorExtensions;
}
@@ -765,7 +783,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", isString=").append(isString);
sb.append(", isNumeric=").append(isNumeric);
sb.append(", isInteger=").append(isInteger);
+ sb.append(", isShort=").append(isShort);
sb.append(", isLong=").append(isLong);
+ sb.append(", isUnboundedInteger=").append(isUnboundedInteger);
sb.append(", isNumber=").append(isNumber);
sb.append(", isFloat=").append(isFloat);
sb.append(", isDouble=").append(isDouble);
@@ -838,7 +858,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
isString == that.isString &&
isNumeric == that.isNumeric &&
isInteger == that.isInteger &&
+ isShort == that.isShort &&
isLong == that.isLong &&
+ isUnboundedInteger == that.isUnboundedInteger &&
isNumber == that.isNumber &&
isFloat == that.isFloat &&
isDouble == that.isDouble &&
@@ -926,7 +948,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric,
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject,
- isArray, isMap, isEnum, isReadOnly, isWriteOnly, isNullable,
+ isArray, isMap, isEnum, isReadOnly, isWriteOnly, isNullable, isShort, isUnboundedInteger,
isSelfReference, isCircularReference, isDiscriminator, _enum, allowableValues,
items, mostInnerItems, additionalProperties, vars, requiredVars,
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
index bb062c1304f..d8c1756f446 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
@@ -36,7 +36,9 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public boolean isString;
public boolean isNumeric;
public boolean isInteger;
+ public boolean isShort;
public boolean isLong;
+ public boolean isUnboundedInteger;
public boolean isNumber;
public boolean isFloat;
public boolean isDouble;
@@ -89,7 +91,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate,
isDateTime, isUuid, isEmail, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
isMap, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
- vars, requiredVars, isNull, hasValidation,
+ vars, requiredVars, isNull, hasValidation, isShort, isUnboundedInteger,
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired);
@@ -104,7 +106,9 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
isString == that.isString &&
isNumeric == that.isNumeric &&
isInteger == that.isInteger &&
+ isShort == that.isShort &&
isLong == that.isLong &&
+ isUnboundedInteger == that.isUnboundedInteger &&
isNumber == that.isNumber &&
isFloat == that.isFloat &&
isDouble == that.isDouble &&
@@ -316,6 +320,22 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
this.isArray = isArray;
}
+ @Override
+ public boolean getIsShort() { return isShort; }
+
+ @Override
+ public void setIsShort(boolean isShort) {
+ this.isShort = isShort;
+ }
+
+ @Override
+ public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
+
+ @Override
+ public void setIsUnboundedInteger(boolean isUnboundedInteger) {
+ this.isUnboundedInteger = isUnboundedInteger;
+ }
+
@Override
public void setIsModel(boolean isModel) {
this.isModel = isModel;
@@ -402,7 +422,9 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
sb.append(", isString=").append(isString);
sb.append(", isNumeric=").append(isNumeric);
sb.append(", isInteger=").append(isInteger);
+ sb.append(", isShort=").append(isShort);
sb.append(", isLong=").append(isLong);
+ sb.append(", isUnboundedInteger=").append(isUnboundedInteger);
sb.append(", isNumber=").append(isNumber);
sb.append(", isFloat=").append(isFloat);
sb.append(", isDouble=").append(isDouble);
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 2edf1bf15af..c26a4df1362 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
@@ -2532,8 +2532,13 @@ public class DefaultCodegen implements CodegenConfig {
m.isNumeric = Boolean.TRUE;
if (ModelUtils.isLongSchema(schema)) { // int64/long format
m.isLong = Boolean.TRUE;
- } else { // int32 format
- m.isInteger = Boolean.TRUE;
+ } else {
+ m.isInteger = Boolean.TRUE; // older use case, int32 and unbounded int
+ if (ModelUtils.isShortSchema(schema)) { // int32
+ m.setIsShort(Boolean.TRUE);
+ } else { // unbounded integer
+ m.setIsUnboundedInteger(Boolean.TRUE);
+ }
}
} else if (ModelUtils.isDateTimeSchema(schema)) {
// NOTE: DateTime schemas as CodegenModel is a rare use case and may be removed at a later date.
@@ -3192,10 +3197,14 @@ public class DefaultCodegen implements CodegenConfig {
property.isNumeric = Boolean.TRUE;
if (ModelUtils.isLongSchema(p)) { // int64/long format
property.isLong = Boolean.TRUE;
- } else { // int32 format
- property.isInteger = Boolean.TRUE;
+ } else {
+ property.isInteger = Boolean.TRUE; // older use case, int32 and unbounded int
+ if (ModelUtils.isShortSchema(p)) { // int32
+ property.setIsShort(Boolean.TRUE);
+ } else { // unbounded integer
+ property.setIsUnboundedInteger(Boolean.TRUE);
+ }
}
-
} else if (ModelUtils.isBooleanSchema(p)) { // boolean type
property.isBoolean = true;
property.getter = toBooleanGetter(name);
@@ -4067,6 +4076,11 @@ public class DefaultCodegen implements CodegenConfig {
} else if (Boolean.TRUE.equals(cp.isInteger)) {
r.isInteger = true;
r.isNumeric = true;
+ if (Boolean.TRUE.equals(cp.isShort)) {
+ r.isShort = true;
+ } else if (Boolean.TRUE.equals(cp.isUnboundedInteger)) {
+ r.isUnboundedInteger = true;
+ }
} else if (Boolean.TRUE.equals(cp.isNumber)) {
r.isNumber = true;
r.isNumeric = true;
@@ -5383,6 +5397,11 @@ public class DefaultCodegen implements CodegenConfig {
} else if (Boolean.TRUE.equals(property.isInteger)) {
parameter.isInteger = true;
parameter.isPrimitiveType = true;
+ if (Boolean.TRUE.equals(property.isShort)) {
+ parameter.isShort = true;
+ } else if (Boolean.TRUE.equals(property.isUnboundedInteger)) {
+ parameter.isUnboundedInteger = true;
+ }
} else if (Boolean.TRUE.equals(property.isDouble)) {
parameter.isDouble = true;
parameter.isPrimitiveType = true;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
index 4eb567b6cdc..ea677853335 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
@@ -77,7 +77,15 @@ public interface IJsonSchemaValidationProperties {
boolean getIsArray();
- void setIsArray(boolean isArray);
+ void setIsArray(boolean isShort);
+
+ boolean getIsShort();
+
+ void setIsShort(boolean isShort);
+
+ boolean getIsUnboundedInteger();
+
+ void setIsUnboundedInteger(boolean isUnboundedInteger);
CodegenProperty getAdditionalProperties();
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
index e125c98a463..1d249e687e4 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
@@ -3437,4 +3437,127 @@ public class DefaultCodegenTest {
}
}
}
+
+ @Test
+ public void testBooleansSetForIntSchemas() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_9447.yaml");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ codegen.setOpenAPI(openAPI);
+ codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
+
+ String modelName;
+ Schema sc;
+ CodegenModel cm;
+
+ modelName = "UnboundedInteger";
+ sc = openAPI.getComponents().getSchemas().get(modelName);
+ cm = codegen.fromModel(modelName, sc);
+ assertEquals(cm.isUnboundedInteger, true);
+ assertEquals(cm.isInteger, true);
+ assertEquals(cm.isShort, false);
+ assertEquals(cm.isLong, false);
+
+ modelName = "Int32";
+ sc = openAPI.getComponents().getSchemas().get(modelName);
+ cm = codegen.fromModel(modelName, sc);
+ assertEquals(cm.isUnboundedInteger, false);
+ assertEquals(cm.isInteger, true);
+ assertEquals(cm.isShort, true);
+ assertEquals(cm.isLong, false);
+
+ modelName = "Int64";
+ sc = openAPI.getComponents().getSchemas().get(modelName);
+ cm = codegen.fromModel(modelName, sc);
+ assertEquals(cm.isUnboundedInteger, false);
+ assertEquals(cm.isInteger, false);
+ assertEquals(cm.isShort, false);
+ assertEquals(cm.isLong, true);
+
+ modelName = "ObjectModelWithIntegerProps";
+ sc = openAPI.getComponents().getSchemas().get(modelName);
+ cm = codegen.fromModel(modelName, sc);
+ assertEquals(cm.isUnboundedInteger, false);
+ assertEquals(cm.isInteger, false);
+ assertEquals(cm.isShort, false);
+ assertEquals(cm.isLong, false);
+ CodegenProperty cp;
+ cp = cm.vars.get(0);
+ assertEquals(cp.isUnboundedInteger, true);
+ assertEquals(cp.isInteger, true);
+ assertEquals(cp.isShort, false);
+ assertEquals(cp.isLong, false);
+ cp = cm.vars.get(1);
+ assertEquals(cp.isUnboundedInteger, false);
+ assertEquals(cp.isInteger, true);
+ assertEquals(cp.isShort, true);
+ assertEquals(cp.isLong, false);
+ cp = cm.vars.get(2);
+ assertEquals(cp.isUnboundedInteger, false);
+ assertEquals(cp.isInteger, false);
+ assertEquals(cp.isShort, false);
+ assertEquals(cp.isLong, true);
+
+ String path;
+ Operation operation;
+ CodegenOperation co;
+ CodegenParameter cpa;
+ CodegenResponse cr;
+
+ path = "/UnboundedInteger";
+ operation = openAPI.getPaths().get(path).getPost();
+ co = codegen.fromOperation(path, "POST", operation, null);
+ cpa = co.pathParams.get(0);
+ assertEquals(cpa.isUnboundedInteger, true);
+ assertEquals(cpa.isInteger, true);
+ assertEquals(cpa.isShort, false);
+ assertEquals(cpa.isLong, false);
+ cpa = co.bodyParam;
+ assertEquals(cpa.isUnboundedInteger, true);
+ assertEquals(cpa.isInteger, true);
+ assertEquals(cpa.isShort, false);
+ assertEquals(cpa.isLong, false);
+ cr = co.responses.get(0);
+ assertEquals(cr.isUnboundedInteger, true);
+ assertEquals(cr.isInteger, true);
+ assertEquals(cr.isShort, false);
+ assertEquals(cr.isLong, false);
+
+ path = "/Int32";
+ operation = openAPI.getPaths().get(path).getPost();
+ co = codegen.fromOperation(path, "POST", operation, null);
+ cpa = co.pathParams.get(0);
+ assertEquals(cpa.isUnboundedInteger, false);
+ assertEquals(cpa.isInteger, true);
+ assertEquals(cpa.isShort, true);
+ assertEquals(cpa.isLong, false);
+ cpa = co.bodyParam;
+ assertEquals(cpa.isUnboundedInteger, false);
+ assertEquals(cpa.isInteger, true);
+ assertEquals(cpa.isShort, true);
+ assertEquals(cpa.isLong, false);
+ cr = co.responses.get(0);
+ assertEquals(cr.isUnboundedInteger, false);
+ assertEquals(cr.isInteger, true);
+ assertEquals(cr.isShort, true);
+ assertEquals(cr.isLong, false);
+
+ path = "/Int64";
+ operation = openAPI.getPaths().get(path).getPost();
+ co = codegen.fromOperation(path, "POST", operation, null);
+ cpa = co.pathParams.get(0);
+ assertEquals(cpa.isUnboundedInteger, false);
+ assertEquals(cpa.isInteger, false);
+ assertEquals(cpa.isShort, false);
+ assertEquals(cpa.isLong, true);
+ cpa = co.bodyParam;
+ assertEquals(cpa.isUnboundedInteger, false);
+ assertEquals(cpa.isInteger, false);
+ assertEquals(cpa.isShort, false);
+ assertEquals(cpa.isLong, true);
+ cr = co.responses.get(0);
+ assertEquals(cr.isUnboundedInteger, false);
+ assertEquals(cr.isInteger, false);
+ assertEquals(cr.isShort, false);
+ assertEquals(cr.isLong, true);
+ }
}
diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_9447.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_9447.yaml
new file mode 100644
index 00000000000..7cfa010c37f
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/issue_9447.yaml
@@ -0,0 +1,106 @@
+openapi: 3.0.1
+info:
+ title: OpenAPI Petstore
+ description: "sample to vet integer handling"
+ license:
+ name: Apache-2.0
+ url: https://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.0
+servers:
+ - url: http://petstore.swagger.io:80/v2
+tags: []
+paths:
+ /UnboundedInteger:
+ post:
+ operationId: UnboundedInteger
+ parameters:
+ - name: UnboundedInteger
+ in: path
+ required: true
+ schema:
+ type: integer
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: integer
+ required: true
+ responses:
+ 200:
+ description: success
+ content:
+ application/json:
+ schema:
+ type: integer
+ /Int64:
+ post:
+ operationId: Int64
+ parameters:
+ - name: Int64
+ in: path
+ required: true
+ schema:
+ type: integer
+ format: int64
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: integer
+ format: int64
+ required: true
+ responses:
+ 200:
+ description: success
+ content:
+ application/json:
+ schema:
+ type: integer
+ format: int64
+ /Int32:
+ post:
+ operationId: Int32
+ parameters:
+ - name: Int32
+ in: path
+ required: true
+ schema:
+ type: integer
+ format: int32
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: integer
+ format: int32
+ required: true
+ responses:
+ 200:
+ description: success
+ content:
+ application/json:
+ schema:
+ type: integer
+ format: int32
+components:
+ schemas:
+ UnboundedInteger:
+ type: integer
+ Int32:
+ type: integer
+ format: int32
+ Int64:
+ type: integer
+ format: int64
+ ObjectModelWithIntegerProps:
+ type: object
+ properties:
+ UnboundedInteger:
+ type: integer
+ Int32:
+ type: integer
+ format: int32
+ Int64:
+ type: integer
+ format: int64
+ securitySchemes: {}
\ No newline at end of file
diff --git a/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java b/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java
index 41b91a89132..362ae244118 100644
--- a/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java
+++ b/samples/server/petstore/java-undertow/src/main/java/org/openapitools/handler/PathHandlerInterface.java
@@ -539,10 +539,10 @@ public interface PathHandlerInterface {
* Response headers: [CodegenProperty{openApiType='integer', baseName='X-Rate-Limit', complexType='null', getter='getxRateLimit', setter='setxRateLimit', description='calls per hour allowed by the user', dataType='Integer', datatypeWithEnum='Integer', dataFormat='int32', name='xRateLimit', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Rate-Limit;', baseType='Integer', containerType='null', title='null', unescapedDescription='calls per hour allowed by the user', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
"type" : "integer",
"format" : "int32"
-}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=false, isNumeric=true, isInteger=true, isLong=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=false, isUuid=false, isUri=false, isEmail=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XRateLimit', nameInSnakeCase='X_RATE_LIMIT', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false}, CodegenProperty{openApiType='string', baseName='X-Expires-After', complexType='Date', getter='getxExpiresAfter', setter='setxExpiresAfter', description='date in UTC when toekn expires', dataType='Date', datatypeWithEnum='Date', dataFormat='date-time', name='xExpiresAfter', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Expires-After;', baseType='Date', containerType='null', title='null', unescapedDescription='date in UTC when toekn expires', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
+}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=false, isNumeric=true, isInteger=true, isShort=true, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=false, isUuid=false, isUri=false, isEmail=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XRateLimit', nameInSnakeCase='X_RATE_LIMIT', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false}, CodegenProperty{openApiType='string', baseName='X-Expires-After', complexType='Date', getter='getxExpiresAfter', setter='setxExpiresAfter', description='date in UTC when toekn expires', dataType='Date', datatypeWithEnum='Date', dataFormat='date-time', name='xExpiresAfter', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Expires-After;', baseType='Date', containerType='null', title='null', unescapedDescription='date in UTC when toekn expires', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
"type" : "string",
"format" : "date-time"
-}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=false, isModel=false, isContainer=false, isString=false, isNumeric=false, isInteger=false, isLong=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=true, isUuid=false, isUri=false, isEmail=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XExpiresAfter', nameInSnakeCase='X_EXPIRES_AFTER', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false}]
+}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=false, isModel=false, isContainer=false, isString=false, isNumeric=false, isInteger=false, isShort=false, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=true, isUuid=false, isUri=false, isEmail=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='XExpiresAfter', nameInSnakeCase='X_EXPIRES_AFTER', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false}]
*
* Produces: [{mediaType=application/xml}, {mediaType=application/json}]
* Returns: {@link String}