From e06665f368bcf2cfc246890ddcba1b7e4adbb8ab Mon Sep 17 00:00:00 2001 From: john lilley Date: Tue, 23 Oct 2018 02:52:36 -0600 Subject: [PATCH] Set isModel property (#1275) * Set isModel property * Replace tab characters --- .../java/org/openapitools/codegen/CodegenParameter.java | 7 ++++++- .../java/org/openapitools/codegen/CodegenProperty.java | 7 ++++++- .../main/java/org/openapitools/codegen/DefaultCodegen.java | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) 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 d290aa5c6ab..661f5e2dcf5 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 @@ -25,7 +25,7 @@ import java.util.Map; public class CodegenParameter { public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, hasMore, isContainer, - secondaryParam, isCollectionFormatMulti, isPrimitiveType; + secondaryParam, isCollectionFormatMulti, isPrimitiveType, isModel; public String baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName; @@ -110,6 +110,7 @@ public class CodegenParameter { output.collectionFormat = this.collectionFormat; output.isCollectionFormatMulti = this.isCollectionFormatMulti; output.isPrimitiveType = this.isPrimitiveType; + output.isModel = this.isModel; output.description = this.description; output.unescapedDescription = this.unescapedDescription; output.baseType = this.baseType; @@ -201,6 +202,8 @@ public class CodegenParameter { return false; if (isPrimitiveType != that.isPrimitiveType) return false; + if (isModel != that.isModel) + return false; if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null) return false; if (paramName != null ? !paramName.equals(that.paramName) : that.paramName != null) @@ -312,6 +315,7 @@ public class CodegenParameter { result = 31 * result + (secondaryParam ? 13:31); result = 31 * result + (isCollectionFormatMulti ? 13:31); result = 31 * result + (isPrimitiveType ? 13:31); + result = 31 * result + (isModel ? 13:31); result = 31 * result + (baseName != null ? baseName.hashCode() : 0); result = 31 * result + (paramName != null ? paramName.hashCode() : 0); result = 31 * result + (dataType != null ? dataType.hashCode() : 0); @@ -378,6 +382,7 @@ public class CodegenParameter { ", secondaryParam=" + secondaryParam + ", isCollectionFormatMulti=" + isCollectionFormatMulti + ", isPrimitiveType=" + isPrimitiveType + + ", isModel=" + isModel + ", baseName='" + baseName + '\'' + ", paramName='" + paramName + '\'' + ", dataType='" + dataType + '\'' + 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 de026b2d3e0..fd3e27988ec 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 @@ -55,7 +55,7 @@ public class CodegenProperty implements Cloneable { public boolean exclusiveMaximum; public boolean hasMore, required, secondaryParam; public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly - public boolean isPrimitiveType, isContainer, isNotContainer; + public boolean isPrimitiveType, isModel, isContainer, isNotContainer; public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid; public boolean isListContainer, isMapContainer; public boolean isEnum; @@ -438,6 +438,7 @@ public class CodegenProperty implements Cloneable { result = prime * result + (isEnum ? 1231 : 1237); result = prime * result + ((isNotContainer ? 13:31)); result = prime * result + ((isPrimitiveType ? 13:31)); + result = prime * result + ((isModel ? 13:31)); result = prime * result + ((isReadOnly ? 13:31)); result = prime * result + ((isWriteOnly ? 13:31)); result = prime * result + ((isNullable ? 13:31)); @@ -579,6 +580,9 @@ public class CodegenProperty implements Cloneable { if (this.isPrimitiveType != other.isPrimitiveType) { return false; } + if (this.isModel != other.isModel) { + return false; + } if (this.isContainer != other.isContainer) { return false; } @@ -759,6 +763,7 @@ public class CodegenProperty implements Cloneable { ", secondaryParam=" + secondaryParam + ", hasMoreNonReadOnly=" + hasMoreNonReadOnly + ", isPrimitiveType=" + isPrimitiveType + + ", isModel=" + isModel + ", isContainer=" + isContainer + ", isNotContainer=" + isNotContainer + ", isString=" + isString + 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 3e5cef43850..b7d74c78ec4 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 @@ -2175,6 +2175,7 @@ public class DefaultCodegen implements CodegenConfig { property.isPrimitiveType = true; } else { property.complexType = property.baseType; + property.isModel = true; } } @@ -4515,6 +4516,9 @@ public class DefaultCodegen implements CodegenConfig { schema.setName(name); codegenModel = fromModel(name, schema, schemas); } + if (codegenModel != null) { + codegenParameter.isModel = true; + } if (codegenModel != null && !codegenModel.emptyVars) { if (StringUtils.isEmpty(bodyParameterName)) {