forked from loafle/openapi-generator-original
Refactor Boolean properties to boolean. (#4326)
There is no good reason to use Boolean instead of boolean. Using Boolean will lead to handling "null" state which is confusing. This change removes changes the type of Boolean properties to boolean.
This commit is contained in:
committed by
wing328
parent
6e578f437f
commit
c83c813865
@@ -39,8 +39,8 @@ public class CodegenModel {
|
||||
public Set<String> allMandatory;
|
||||
|
||||
public Set<String> imports = new TreeSet<String>();
|
||||
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, isArrayModel, hasChildren;
|
||||
public Boolean hasOnlyReadOnly = true; // true if all properties are read-only
|
||||
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, isArrayModel, hasChildren;
|
||||
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
|
||||
public ExternalDocs externalDocs;
|
||||
|
||||
public Map<String, Object> vendorExtensions;
|
||||
@@ -115,15 +115,15 @@ public class CodegenModel {
|
||||
return false;
|
||||
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
|
||||
return false;
|
||||
if (hasVars != null ? !hasVars.equals(that.hasVars) : that.hasVars != null)
|
||||
if (hasVars != that.hasVars)
|
||||
return false;
|
||||
if (emptyVars != null ? !emptyVars.equals(that.emptyVars) : that.emptyVars != null)
|
||||
if (emptyVars != that.emptyVars)
|
||||
return false;
|
||||
if (hasMoreModels != null ? !hasMoreModels.equals(that.hasMoreModels) : that.hasMoreModels != null)
|
||||
if (hasMoreModels != that.hasMoreModels)
|
||||
return false;
|
||||
if (hasEnums != null ? !hasEnums.equals(that.hasEnums) : that.hasEnums != null)
|
||||
if (hasEnums != that.hasEnums)
|
||||
return false;
|
||||
if (isEnum != null ? !isEnum.equals(that.isEnum) : that.isEnum != null)
|
||||
if (isEnum != that.isEnum)
|
||||
return false;
|
||||
if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null)
|
||||
return false;
|
||||
@@ -163,11 +163,11 @@ public class CodegenModel {
|
||||
result = 31 * result + (mandatory != null ? mandatory.hashCode() : 0);
|
||||
result = 31 * result + (allMandatory != null ? allMandatory.hashCode() : 0);
|
||||
result = 31 * result + (imports != null ? imports.hashCode() : 0);
|
||||
result = 31 * result + (hasVars != null ? hasVars.hashCode() : 0);
|
||||
result = 31 * result + (emptyVars != null ? emptyVars.hashCode() : 0);
|
||||
result = 31 * result + (hasMoreModels != null ? hasMoreModels.hashCode() : 0);
|
||||
result = 31 * result + (hasEnums != null ? hasEnums.hashCode() : 0);
|
||||
result = 31 * result + (isEnum != null ? isEnum.hashCode() : 0);
|
||||
result = 31 * result + (hasVars ? 13:31);
|
||||
result = 31 * result + (emptyVars ? 13:31);
|
||||
result = 31 * result + (hasMoreModels ? 13:31);
|
||||
result = 31 * result + (hasEnums ? 13:31);
|
||||
result = 31 * result + (isEnum ? 13:31);
|
||||
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0);
|
||||
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||
result = 31 * result + Objects.hash(hasOnlyReadOnly);
|
||||
|
||||
@@ -11,10 +11,10 @@ import java.util.Arrays;
|
||||
|
||||
public class CodegenOperation {
|
||||
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
|
||||
public Boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
|
||||
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
|
||||
returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMapContainer,
|
||||
isListContainer, isMultipart, hasMore = Boolean.TRUE,
|
||||
isResponseBinary = Boolean.FALSE, hasReference = Boolean.FALSE,
|
||||
isListContainer, isMultipart, hasMore = true,
|
||||
isResponseBinary = false, hasReference = false,
|
||||
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
@@ -189,33 +189,33 @@ public class CodegenOperation {
|
||||
|
||||
if (responseHeaders != null ? !responseHeaders.equals(that.responseHeaders) : that.responseHeaders != null)
|
||||
return false;
|
||||
if (hasAuthMethods != null ? !hasAuthMethods.equals(that.hasAuthMethods) : that.hasAuthMethods != null)
|
||||
if (hasAuthMethods != that.hasAuthMethods)
|
||||
return false;
|
||||
if (hasConsumes != null ? !hasConsumes.equals(that.hasConsumes) : that.hasConsumes != null)
|
||||
if (hasConsumes != that.hasConsumes)
|
||||
return false;
|
||||
if (hasProduces != null ? !hasProduces.equals(that.hasProduces) : that.hasProduces != null)
|
||||
if (hasProduces != that.hasProduces)
|
||||
return false;
|
||||
if (hasParams != null ? !hasParams.equals(that.hasParams) : that.hasParams != null)
|
||||
if (hasParams != that.hasParams)
|
||||
return false;
|
||||
if (hasOptionalParams != null ? !hasOptionalParams.equals(that.hasOptionalParams) : that.hasOptionalParams != null)
|
||||
if (hasOptionalParams != that.hasOptionalParams)
|
||||
return false;
|
||||
if (returnTypeIsPrimitive != null ? !returnTypeIsPrimitive.equals(that.returnTypeIsPrimitive) : that.returnTypeIsPrimitive != null)
|
||||
if (returnTypeIsPrimitive != that.returnTypeIsPrimitive)
|
||||
return false;
|
||||
if (returnSimpleType != null ? !returnSimpleType.equals(that.returnSimpleType) : that.returnSimpleType != null)
|
||||
if (returnSimpleType != that.returnSimpleType)
|
||||
return false;
|
||||
if (subresourceOperation != null ? !subresourceOperation.equals(that.subresourceOperation) : that.subresourceOperation != null)
|
||||
if (subresourceOperation != that.subresourceOperation)
|
||||
return false;
|
||||
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||
if (isMapContainer != that.isMapContainer)
|
||||
return false;
|
||||
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||
if (isListContainer != that.isListContainer)
|
||||
return false;
|
||||
if (isMultipart != null ? !isMultipart.equals(that.isMultipart) : that.isMultipart != null)
|
||||
if (isMultipart != that.isMultipart)
|
||||
return false;
|
||||
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||
if (hasMore != that.hasMore)
|
||||
return false;
|
||||
if (isResponseBinary != null ? !isResponseBinary.equals(that.isResponseBinary) : that.isResponseBinary != null)
|
||||
if (isResponseBinary != that.isResponseBinary)
|
||||
return false;
|
||||
if (hasReference != null ? !hasReference.equals(that.hasReference) : that.hasReference != null)
|
||||
if (hasReference != that.hasReference)
|
||||
return false;
|
||||
if (path != null ? !path.equals(that.path) : that.path != null)
|
||||
return false;
|
||||
@@ -284,20 +284,20 @@ public class CodegenOperation {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = responseHeaders.hashCode();
|
||||
result = 31 * result + (hasAuthMethods != null ? hasAuthMethods.hashCode() : 0);
|
||||
result = 31 * result + (hasConsumes != null ? hasConsumes.hashCode() : 0);
|
||||
result = 31 * result + (hasProduces != null ? hasProduces.hashCode() : 0);
|
||||
result = 31 * result + (hasParams != null ? hasParams.hashCode() : 0);
|
||||
result = 31 * result + (hasOptionalParams != null ? hasOptionalParams.hashCode() : 0);
|
||||
result = 31 * result + (returnTypeIsPrimitive != null ? returnTypeIsPrimitive.hashCode() : 0);
|
||||
result = 31 * result + (returnSimpleType != null ? returnSimpleType.hashCode() : 0);
|
||||
result = 31 * result + (subresourceOperation != null ? subresourceOperation.hashCode() : 0);
|
||||
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||
result = 31 * result + (isMultipart != null ? isMultipart.hashCode() : 0);
|
||||
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||
result = 31 * result + (isResponseBinary != null ? isResponseBinary.hashCode() : 0);
|
||||
result = 31 * result + (hasReference != null ? hasReference.hashCode() : 0);
|
||||
result = 31 * result + (hasAuthMethods ? 13:31);
|
||||
result = 31 * result + (hasConsumes ? 13:31);
|
||||
result = 31 * result + (hasProduces ? 13:31);
|
||||
result = 31 * result + (hasParams ? 13:31);
|
||||
result = 31 * result + (hasOptionalParams ? 13:31);
|
||||
result = 31 * result + (returnTypeIsPrimitive ? 13:31);
|
||||
result = 31 * result + (returnSimpleType ? 13:31);
|
||||
result = 31 * result + (subresourceOperation ? 13:31);
|
||||
result = 31 * result + (isMapContainer ? 13:31);
|
||||
result = 31 * result + (isListContainer ? 13:31);
|
||||
result = 31 * result + (isMultipart ? 13:31);
|
||||
result = 31 * result + (hasMore ? 13:31);
|
||||
result = 31 * result + (isResponseBinary ? 13:31);
|
||||
result = 31 * result + (hasReference ? 13:31);
|
||||
result = 31 * result + (path != null ? path.hashCode() : 0);
|
||||
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
|
||||
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
|
||||
|
||||
@@ -32,21 +32,21 @@ public class CodegenProperty implements Cloneable {
|
||||
public String jsonSchema;
|
||||
public String minimum;
|
||||
public String maximum;
|
||||
public Boolean exclusiveMinimum;
|
||||
public Boolean exclusiveMaximum;
|
||||
public Boolean hasMore, required, secondaryParam;
|
||||
public Boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
||||
public Boolean isListContainer, isMapContainer;
|
||||
public boolean exclusiveMinimum;
|
||||
public boolean exclusiveMaximum;
|
||||
public boolean hasMore, required, secondaryParam;
|
||||
public boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
||||
public boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
||||
public boolean isListContainer, isMapContainer;
|
||||
public boolean isEnum;
|
||||
public Boolean isReadOnly = false;
|
||||
public boolean isReadOnly = false;
|
||||
public List<String> _enum;
|
||||
public Map<String, Object> allowableValues;
|
||||
public CodegenProperty items;
|
||||
public Map<String, Object> vendorExtensions;
|
||||
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||
public Boolean isInherited;
|
||||
public boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||
public boolean isInherited;
|
||||
public String nameInCamelCase; // property name in camel case
|
||||
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
|
||||
public String enumName;
|
||||
@@ -75,16 +75,16 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + ((defaultValueWithParam == null) ? 0 : defaultValueWithParam.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((example == null) ? 0 : example.hashCode());
|
||||
result = prime * result + ((exclusiveMaximum == null) ? 0 : exclusiveMaximum.hashCode());
|
||||
result = prime * result + ((exclusiveMinimum == null) ? 0 : exclusiveMinimum.hashCode());
|
||||
result = prime * result + (exclusiveMaximum ? 13:31);
|
||||
result = prime * result + (exclusiveMinimum ? 13:31);
|
||||
result = prime * result + ((getter == null) ? 0 : getter.hashCode());
|
||||
result = prime * result + ((hasMore == null) ? 0 : hasMore.hashCode());
|
||||
result = prime * result + ((hasMoreNonReadOnly == null) ? 0 : hasMoreNonReadOnly.hashCode());
|
||||
result = prime * result + ((isContainer == null) ? 0 : isContainer.hashCode());
|
||||
result = prime * result + (hasMore ? 13:31);
|
||||
result = prime * result + ((hasMoreNonReadOnly ? 13:31));
|
||||
result = prime * result + ((isContainer ? 13:31));
|
||||
result = prime * result + (isEnum ? 1231 : 1237);
|
||||
result = prime * result + ((isNotContainer == null) ? 0 : isNotContainer.hashCode());
|
||||
result = prime * result + ((isPrimitiveType == null) ? 0 : isPrimitiveType.hashCode());
|
||||
result = prime * result + ((isReadOnly == null) ? 0 : isReadOnly.hashCode());
|
||||
result = prime * result + ((isNotContainer ? 13:31));
|
||||
result = prime * result + ((isPrimitiveType ? 13:31));
|
||||
result = prime * result + ((isReadOnly ? 13:31));
|
||||
result = prime * result + ((items == null) ? 0 : items.hashCode());
|
||||
result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode());
|
||||
result = prime * result + ((max == null) ? 0 : max.hashCode());
|
||||
@@ -95,24 +95,24 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + ((minimum == null) ? 0 : minimum.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
|
||||
result = prime * result + ((required == null) ? 0 : required.hashCode());
|
||||
result = prime * result + ((secondaryParam == null) ? 0 : secondaryParam.hashCode());
|
||||
result = prime * result + ((required ? 13:31));
|
||||
result = prime * result + ((secondaryParam ? 13:31));
|
||||
result = prime * result + ((setter == null) ? 0 : setter.hashCode());
|
||||
result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode());
|
||||
result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode());
|
||||
result = prime * result + ((hasValidation == null) ? 0 : hasValidation.hashCode());
|
||||
result = prime * result + ((isString == null) ? 0 : isString.hashCode());
|
||||
result = prime * result + ((isInteger == null) ? 0 : isInteger.hashCode());
|
||||
result = prime * result + ((isLong == null) ? 0 : isLong.hashCode());
|
||||
result = prime * result + ((isFloat == null) ? 0 : isFloat.hashCode());
|
||||
result = prime * result + ((isDouble == null) ? 0 : isDouble.hashCode());
|
||||
result = prime * result + ((isByteArray == null) ? 0 : isByteArray.hashCode());
|
||||
result = prime * result + ((isBinary == null) ? 0 : isBinary.hashCode());
|
||||
result = prime * result + ((isBoolean == null) ? 0 : isBoolean.hashCode());
|
||||
result = prime * result + ((isDate == null) ? 0 : isDate.hashCode());
|
||||
result = prime * result + ((isDateTime == null) ? 0 : isDateTime.hashCode());
|
||||
result = prime * result + ((isMapContainer == null) ? 0 : isMapContainer.hashCode());
|
||||
result = prime * result + ((isListContainer == null) ? 0 : isListContainer.hashCode());
|
||||
result = prime * result + ((hasValidation ? 13:31));
|
||||
result = prime * result + ((isString ? 13:31));
|
||||
result = prime * result + ((isInteger ? 13:31));
|
||||
result = prime * result + ((isLong ?13:31));
|
||||
result = prime * result + ((isFloat ? 13:31));
|
||||
result = prime * result + ((isDouble ? 13:31));
|
||||
result = prime * result + ((isByteArray ? 13:31));
|
||||
result = prime * result + ((isBinary ? 13:31));
|
||||
result = prime * result + ((isBoolean ? 13:31));
|
||||
result = prime * result + ((isDate ? 13:31));
|
||||
result = prime * result + ((isDateTime ? 13:31));
|
||||
result = prime * result + ((isMapContainer ? 13:31));
|
||||
result = prime * result + ((isListContainer ? 13:31));
|
||||
result = prime * result + Objects.hashCode(isInherited);
|
||||
result = prime * result + Objects.hashCode(nameInCamelCase);
|
||||
result = prime * result + Objects.hashCode(enumName);
|
||||
@@ -191,31 +191,31 @@ public class CodegenProperty implements Cloneable {
|
||||
if (this.maximum != other.maximum && (this.maximum == null || !this.maximum.equals(other.maximum))) {
|
||||
return false;
|
||||
}
|
||||
if (this.exclusiveMinimum != other.exclusiveMinimum && (this.exclusiveMinimum == null || !this.exclusiveMinimum.equals(other.exclusiveMinimum))) {
|
||||
if (this.exclusiveMinimum != other.exclusiveMinimum) {
|
||||
return false;
|
||||
}
|
||||
if (this.exclusiveMaximum != other.exclusiveMaximum && (this.exclusiveMaximum == null || !this.exclusiveMaximum.equals(other.exclusiveMaximum))) {
|
||||
if (this.exclusiveMaximum != other.exclusiveMaximum) {
|
||||
return false;
|
||||
}
|
||||
if (this.required != other.required && (this.required == null || !this.required.equals(other.required))) {
|
||||
if (this.required != other.required) {
|
||||
return false;
|
||||
}
|
||||
if (this.secondaryParam != other.secondaryParam && (this.secondaryParam == null || !this.secondaryParam.equals(other.secondaryParam))) {
|
||||
if (this.secondaryParam != other.secondaryParam) {
|
||||
return false;
|
||||
}
|
||||
if (this.isPrimitiveType != other.isPrimitiveType && (this.isPrimitiveType == null || !this.isPrimitiveType.equals(other.isPrimitiveType))) {
|
||||
if (this.isPrimitiveType != other.isPrimitiveType) {
|
||||
return false;
|
||||
}
|
||||
if (this.isContainer != other.isContainer && (this.isContainer == null || !this.isContainer.equals(other.isContainer))) {
|
||||
if (this.isContainer != other.isContainer) {
|
||||
return false;
|
||||
}
|
||||
if (this.isNotContainer != other.isNotContainer && (this.isNotContainer == null || !this.isNotContainer.equals(other.isNotContainer))) {
|
||||
if (this.isNotContainer != other.isNotContainer) {
|
||||
return false;
|
||||
}
|
||||
if (this.isEnum != other.isEnum) {
|
||||
return false;
|
||||
}
|
||||
if (this.isReadOnly != other.isReadOnly && (this.isReadOnly == null || !this.isReadOnly.equals(other.isReadOnly))) {
|
||||
if (this.isReadOnly != other.isReadOnly) {
|
||||
return false;
|
||||
}
|
||||
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
|
||||
@@ -229,45 +229,45 @@ public class CodegenProperty implements Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.hasValidation != other.hasValidation && (this.hasValidation == null || !this.hasValidation.equals(other.hasValidation))) {
|
||||
if (this.hasValidation != other.hasValidation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isString != other.isString && (this.isString == null || !this.isString.equals(other.isString))) {
|
||||
if (this.isString != other.isString) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isInteger != other.isInteger && (this.isInteger == null || !this.isInteger.equals(other.isInteger))) {
|
||||
if (this.isInteger != other.isInteger) {
|
||||
return false;
|
||||
}
|
||||
if (this.isLong != other.isLong && (this.isLong == null || !this.isLong.equals(other.isLong))) {
|
||||
if (this.isLong != other.isLong) {
|
||||
return false;
|
||||
}
|
||||
if (this.isFloat != other.isFloat && (this.isFloat == null || !this.isFloat.equals(other.isFloat))) {
|
||||
if (this.isFloat != other.isFloat) {
|
||||
return false;
|
||||
}
|
||||
if (this.isDouble != other.isDouble && (this.isDouble == null || !this.isDouble.equals(other.isDouble))) {
|
||||
if (this.isDouble != other.isDouble) {
|
||||
return false;
|
||||
}
|
||||
if (this.isByteArray != other.isByteArray && (this.isByteArray == null || !this.isByteArray.equals(other.isByteArray))) {
|
||||
if (this.isByteArray != other.isByteArray) {
|
||||
return false;
|
||||
}
|
||||
if (this.isBoolean != other.isBoolean && (this.isBoolean == null || !this.isBoolean.equals(other.isBoolean))) {
|
||||
if (this.isBoolean != other.isBoolean) {
|
||||
return false;
|
||||
}
|
||||
if (this.isDate != other.isDate && (this.isDate == null || !this.isDate.equals(other.isDate))) {
|
||||
if (this.isDate != other.isDate) {
|
||||
return false;
|
||||
}
|
||||
if (this.isDateTime != other.isDateTime && (this.isDateTime == null || !this.isDateTime.equals(other.isDateTime))) {
|
||||
if (this.isDateTime != other.isDateTime) {
|
||||
return false;
|
||||
}
|
||||
if (this.isBinary != other.isBinary && (this.isBinary == null || !this.isBinary.equals(other.isBinary))) {
|
||||
if (this.isBinary != other.isBinary) {
|
||||
return false;
|
||||
}
|
||||
if (this.isListContainer != other.isListContainer && (this.isListContainer == null || !this.isListContainer.equals(other.isListContainer))) {
|
||||
if (this.isListContainer != other.isListContainer) {
|
||||
return false;
|
||||
}
|
||||
if (this.isMapContainer != other.isMapContainer && (this.isMapContainer == null || !this.isMapContainer.equals(other.isMapContainer))) {
|
||||
if (this.isMapContainer != other.isMapContainer) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.isInherited, other.isInherited)) {
|
||||
|
||||
@@ -1241,7 +1241,6 @@ public class DefaultCodegen {
|
||||
if (model instanceof ArrayModel) {
|
||||
ArrayModel am = (ArrayModel) model;
|
||||
ArrayProperty arrayProperty = new ArrayProperty(am.getItems());
|
||||
m.hasEnums = false; // Otherwise there will be a NullPointerException in JavaClientCodegen.fromModel
|
||||
m.isArrayModel = true;
|
||||
m.arrayModelType = fromProperty(name, arrayProperty).complexType;
|
||||
addParentContainer(m, name, arrayProperty);
|
||||
@@ -1438,36 +1437,35 @@ public class DefaultCodegen {
|
||||
property.defaultValue = toDefaultValue(p);
|
||||
property.defaultValueWithParam = toDefaultValueWithParam(name, p);
|
||||
property.jsonSchema = Json.pretty(p);
|
||||
property.isReadOnly = p.getReadOnly();
|
||||
if (p.getReadOnly() != null) {
|
||||
property.isReadOnly = p.getReadOnly();
|
||||
}
|
||||
property.vendorExtensions = p.getVendorExtensions();
|
||||
|
||||
String type = getSwaggerType(p);
|
||||
if (p instanceof AbstractNumericProperty) {
|
||||
AbstractNumericProperty np = (AbstractNumericProperty) p;
|
||||
if (np.getMinimum() != null) {
|
||||
if (p instanceof BaseIntegerProperty) { // int, long
|
||||
property.minimum = String.valueOf(np.getMinimum().longValue());
|
||||
} else { // double, decimal
|
||||
property.minimum = String.valueOf(np.getMinimum());
|
||||
}
|
||||
} else {
|
||||
// set to null (empty) in mustache
|
||||
property.minimum = null;
|
||||
if (p instanceof BaseIntegerProperty) { // int, long
|
||||
property.minimum = String.valueOf(np.getMinimum().longValue());
|
||||
} else { // double, decimal
|
||||
property.minimum = String.valueOf(np.getMinimum());
|
||||
}
|
||||
}
|
||||
|
||||
if (np.getMaximum() != null) {
|
||||
if (p instanceof BaseIntegerProperty) { // int, long
|
||||
property.maximum = String.valueOf(np.getMaximum().longValue());
|
||||
} else { // double, decimal
|
||||
property.maximum = String.valueOf(np.getMaximum());
|
||||
}
|
||||
} else {
|
||||
// set to null (empty) in mustache
|
||||
property.maximum = null;
|
||||
if (p instanceof BaseIntegerProperty) { // int, long
|
||||
property.maximum = String.valueOf(np.getMaximum().longValue());
|
||||
} else { // double, decimal
|
||||
property.maximum = String.valueOf(np.getMaximum());
|
||||
}
|
||||
}
|
||||
|
||||
property.exclusiveMinimum = np.getExclusiveMinimum();
|
||||
property.exclusiveMaximum = np.getExclusiveMaximum();
|
||||
if (np.getExclusiveMinimum() != null) {
|
||||
property.exclusiveMinimum = np.getExclusiveMinimum();
|
||||
}
|
||||
if (np.getExclusiveMaximum() != null) {
|
||||
property.exclusiveMaximum = np.getExclusiveMaximum();
|
||||
}
|
||||
|
||||
// check if any validation rule defined
|
||||
// exclusive* are noop without corresponding min/max
|
||||
@@ -2030,14 +2028,14 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (cm.isContainer != null) {
|
||||
if (cm.isContainer) {
|
||||
op.returnContainer = cm.containerType;
|
||||
if ("map".equals(cm.containerType)) {
|
||||
op.isMapContainer = Boolean.TRUE;
|
||||
op.isMapContainer = true;
|
||||
} else if ("list".equalsIgnoreCase(cm.containerType)) {
|
||||
op.isListContainer = Boolean.TRUE;
|
||||
op.isListContainer = true;
|
||||
} else if ("array".equalsIgnoreCase(cm.containerType)) {
|
||||
op.isListContainer = Boolean.TRUE;
|
||||
op.isListContainer = true;
|
||||
}
|
||||
} else {
|
||||
op.returnSimpleType = true;
|
||||
@@ -2195,7 +2193,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
r.dataType = cm.datatype;
|
||||
r.isBinary = isDataTypeBinary(cm.datatype);
|
||||
if (cm.isContainer != null) {
|
||||
if (cm.isContainer) {
|
||||
r.simpleType = false;
|
||||
r.containerType = cm.containerType;
|
||||
r.isMapContainer = "map".equals(cm.containerType);
|
||||
@@ -2342,6 +2340,7 @@ public class DefaultCodegen {
|
||||
p.maximum = qp.getMaximum() == null ? null : String.valueOf(qp.getMaximum());
|
||||
p.minimum = qp.getMinimum() == null ? null : String.valueOf(qp.getMinimum());
|
||||
}
|
||||
|
||||
p.exclusiveMaximum = qp.isExclusiveMaximum();
|
||||
p.exclusiveMinimum = qp.isExclusiveMinimum();
|
||||
p.maxLength = qp.getMaxLength();
|
||||
@@ -2371,7 +2370,7 @@ public class DefaultCodegen {
|
||||
if (model instanceof ModelImpl) {
|
||||
ModelImpl impl = (ModelImpl) model;
|
||||
CodegenModel cm = fromModel(bp.getName(), impl);
|
||||
if (cm.emptyVars != null && cm.emptyVars == false) {
|
||||
if (!cm.emptyVars) {
|
||||
p.dataType = getTypeDeclaration(cm.classname);
|
||||
imports.add(p.dataType);
|
||||
} else {
|
||||
@@ -2848,8 +2847,8 @@ public class DefaultCodegen {
|
||||
LOGGER.warn("null property for " + key);
|
||||
} else {
|
||||
final CodegenProperty cp = fromProperty(key, prop);
|
||||
cp.required = mandatory.contains(key) ? true : null;
|
||||
m.hasRequired = Boolean.TRUE.equals(m.hasRequired) || Boolean.TRUE.equals(cp.required);
|
||||
cp.required = mandatory.contains(key) ? true : false;
|
||||
m.hasRequired = m.hasRequired || cp.required;
|
||||
if (cp.isEnum) {
|
||||
// FIXME: if supporting inheritance, when called a second time for allProperties it is possible for
|
||||
// m.hasEnums to be set incorrectly if allProperties has enumerations but properties does not.
|
||||
@@ -2869,7 +2868,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (cp.isContainer != null) {
|
||||
if (cp.isContainer) {
|
||||
addImport(m, typeMapping.get("array"));
|
||||
}
|
||||
|
||||
|
||||
@@ -870,7 +870,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
if (os != null && os.size() > 0) {
|
||||
CodegenOperation op = os.get(os.size() - 1);
|
||||
op.hasMore = null;
|
||||
op.hasMore = false;
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
|
||||
@@ -863,7 +863,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
int count = 0, numVars = codegenProperties.size();
|
||||
for(CodegenProperty codegenProperty : codegenProperties) {
|
||||
count += 1;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : null;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : false;
|
||||
}
|
||||
codegenModel.vars = codegenProperties;
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
||||
opsByPathEntry.put("path", entry.getKey());
|
||||
opsByPathEntry.put("operation", entry.getValue());
|
||||
List<CodegenOperation> operationsForThisPath = Lists.newArrayList(entry.getValue());
|
||||
operationsForThisPath.get(operationsForThisPath.size() - 1).hasMore = null;
|
||||
operationsForThisPath.get(operationsForThisPath.size() - 1).hasMore = false;
|
||||
if (opsByPathList.size() < opsByPath.asMap().size()) {
|
||||
opsByPathEntry.put("hasMore", "true");
|
||||
}
|
||||
|
||||
@@ -927,14 +927,14 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
// set vendor-extension: x-codegen-hasMoreRequired
|
||||
CodegenProperty lastRequired = null;
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (var.required != null && var.required) {
|
||||
if (var.required) {
|
||||
lastRequired = var;
|
||||
}
|
||||
}
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (var == lastRequired) {
|
||||
var.vendorExtensions.put("x-codegen-hasMoreRequired", false);
|
||||
} else if (var.required != null && var.required) {
|
||||
} else if (var.required) {
|
||||
var.vendorExtensions.put("x-codegen-hasMoreRequired", true);
|
||||
}
|
||||
}
|
||||
@@ -996,7 +996,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
int count = 0, numVars = codegenProperties.size();
|
||||
for(CodegenProperty codegenProperty : codegenProperties) {
|
||||
count += 1;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : null;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : false;
|
||||
}
|
||||
codegenModel.vars = codegenProperties;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
opsByPathEntry.put("path", entry.getKey());
|
||||
opsByPathEntry.put("operation", entry.getValue());
|
||||
List<CodegenOperation> operationsForThisPath = Lists.newArrayList(entry.getValue());
|
||||
operationsForThisPath.get(operationsForThisPath.size() - 1).hasMore = null;
|
||||
operationsForThisPath.get(operationsForThisPath.size() - 1).hasMore = false;
|
||||
if (opsByPathList.size() < opsByPath.asMap().size()) {
|
||||
opsByPathEntry.put("hasMore", "true");
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
int count = 0, numVars = codegenProperties.size();
|
||||
for(CodegenProperty codegenProperty : codegenProperties) {
|
||||
count += 1;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : null;
|
||||
codegenProperty.hasMore = (count < numVars) ? true : false;
|
||||
}
|
||||
codegenModel.vars = codegenProperties;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user