Skip to content

Commit

Permalink
Adds isShort + isUnboundedInteger to IJsonSchemaValidationProperties …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
spacether committed May 26, 2021
1 parent 8134362 commit 6e6b847
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -606,6 +606,22 @@ public void setIsArray(boolean isArray) {
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; }

Expand Down Expand Up @@ -752,7 +768,9 @@ public boolean equals(Object o) {
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 &&
Expand Down Expand Up @@ -839,7 +857,7 @@ public int hashCode() {
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,
Expand Down Expand Up @@ -881,7 +899,9 @@ public String toString() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -184,7 +184,9 @@ public CodegenParameter copy() {
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;
Expand All @@ -209,7 +211,7 @@ public CodegenParameter copy() {

@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
Expand All @@ -231,7 +233,9 @@ public boolean equals(Object o) {
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 &&
Expand Down Expand Up @@ -328,7 +332,9 @@ public String toString() {
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);
Expand Down Expand Up @@ -560,6 +566,22 @@ public void setIsArray(boolean isArray) {
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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -507,6 +509,22 @@ public void setIsArray(boolean isArray) {
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;
}
Expand Down Expand Up @@ -765,7 +783,9 @@ public String toString() {
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);
Expand Down Expand Up @@ -838,7 +858,9 @@ public boolean equals(Object o) {
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 &&
Expand Down Expand Up @@ -926,7 +948,7 @@ public int hashCode() {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,7 +91,7 @@ public int hashCode() {
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);
Expand All @@ -104,7 +106,9 @@ public boolean equals(Object o) {
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 &&
Expand Down Expand Up @@ -316,6 +320,22 @@ public void setIsArray(boolean isArray) {
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;
Expand Down Expand Up @@ -402,7 +422,9 @@ public String toString() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2532,8 +2532,13 @@ public CodegenModel fromModel(String name, Schema schema) {
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.
Expand Down Expand Up @@ -3192,10 +3197,14 @@ public CodegenProperty fromProperty(String name, Schema p) {
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);
Expand Down Expand Up @@ -4067,6 +4076,11 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
} 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;
Expand Down Expand Up @@ -5383,6 +5397,11 @@ public void setParameterBooleanFlagWithCodegenProperty(CodegenParameter paramete
} 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 6e6b847

Please sign in to comment.