forked from loafle/openapi-generator-original
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
This commit is contained in:
parent
8134362244
commit
6e6b8472d4
@ -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<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties)
|
||||
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>(); // 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);
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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<String, Object> 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,
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
106
modules/openapi-generator/src/test/resources/3_0/issue_9447.yaml
Normal file
106
modules/openapi-generator/src/test/resources/3_0/issue_9447.yaml
Normal file
@ -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: {}
|
@ -539,10 +539,10 @@ public interface PathHandlerInterface {
|
||||
* <p><b>Response headers</b>: [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}]</p>
|
||||
}', 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}]</p>
|
||||
*
|
||||
* <p><b>Produces</b>: [{mediaType=application/xml}, {mediaType=application/json}]</p>
|
||||
* <p><b>Returns</b>: {@link String}</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user