Skip to content

Commit

Permalink
Add utility methods for free-form objects (isFreeFormObject) (#1338)
Browse files Browse the repository at this point in the history
* add utility methods for models

* add isFreeFormObject tag

* add object mapping for elixir client

* minor fix to free form object check
  • Loading branch information
wing328 authored Nov 22, 2018
1 parent 9be5b99 commit 5aa1da7
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ public class CodegenParameter {
isCookieParam, isBodyParam, hasMore, isContainer,
secondaryParam, isCollectionFormatMulti, isPrimitiveType, isModel;
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat,
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName;
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName;

public String example; // example value (x-example)
public String jsonSchema;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isEmail;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
public boolean isFile;
public boolean isEnum;
Expand Down Expand Up @@ -94,7 +95,7 @@ public class CodegenParameter {
* See http://json-schema.org/latest/json-schema-validation.html#anchor14
*/
public Number multipleOf;

public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
output.isFile = this.isFile;
Expand Down Expand Up @@ -148,7 +149,7 @@ public CodegenParameter copy() {
if (this.mostInnerItems != null) {
output.mostInnerItems = this.mostInnerItems;
}
if(this.vendorExtensions != null){
if (this.vendorExtensions != null) {
output.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions);
}
output.hasValidation = this.hasValidation;
Expand All @@ -167,6 +168,7 @@ public CodegenParameter copy() {
output.isDateTime = this.isDateTime;
output.isUuid = this.isUuid;
output.isEmail = this.isEmail;
output.isFreeFormObject = this.isFreeFormObject;
output.isListContainer = this.isListContainer;
output.isMapContainer = this.isMapContainer;

Expand Down Expand Up @@ -259,6 +261,8 @@ public boolean equals(Object o) {
return false;
if (isEmail != that.isEmail)
return false;
if (isFreeFormObject != that.isFreeFormObject)
return false;
if (isListContainer != that.isListContainer)
return false;
if (isMapContainer != that.isMapContainer)
Expand Down Expand Up @@ -307,18 +311,18 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = isFormParam ? 13:31;
result = 31 * result + (isQueryParam ? 13:31);
result = 31 * result + (isPathParam ? 13:31);
result = 31 * result + (isHeaderParam ? 13:31);
result = 31 * result + (isCookieParam ? 13:31);
result = 31 * result + (isBodyParam ? 13:31);
result = 31 * result + (hasMore ? 13:31);
result = 31 * result + (isContainer ? 13:31);
result = 31 * result + (secondaryParam ? 13:31);
result = 31 * result + (isCollectionFormatMulti ? 13:31);
result = 31 * result + (isPrimitiveType ? 13:31);
result = 31 * result + (isModel ? 13:31);
int result = isFormParam ? 13 : 31;
result = 31 * result + (isQueryParam ? 13 : 31);
result = 31 * result + (isPathParam ? 13 : 31);
result = 31 * result + (isHeaderParam ? 13 : 31);
result = 31 * result + (isCookieParam ? 13 : 31);
result = 31 * result + (isBodyParam ? 13 : 31);
result = 31 * result + (hasMore ? 13 : 31);
result = 31 * result + (isContainer ? 13 : 31);
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);
Expand All @@ -332,42 +336,43 @@ public int hashCode() {
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
result = 31 * result + (example != null ? example.hashCode() : 0);
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
result = 31 * result + (isString ? 13:31);
result = 31 * result + (isNumeric ? 13:31);
result = 31 * result + (isInteger ? 13:31);
result = 31 * result + (isLong ? 13:31);
result = 31 * result + (isFloat ? 13:31);
result = 31 * result + (isNumber ? 13:31);
result = 31 * result + (isDouble ? 13:31);
result = 31 * result + (isByteArray ? 13:31);
result = 31 * result + (isBinary ? 13:31);
result = 31 * result + (isBoolean ? 13:31);
result = 31 * result + (isDate ? 13:31);
result = 31 * result + (isDateTime ? 13:31);
result = 31 * result + (isUuid ? 13:31);
result = 31 * result + (isEmail ? 13:31);
result = 31 * result + (isListContainer ? 13:31);
result = 31 * result + (isMapContainer ? 13:31);
result = 31 * result + (isFile ? 13:31);
result = 31 * result + (isString ? 13 : 31);
result = 31 * result + (isNumeric ? 13 : 31);
result = 31 * result + (isInteger ? 13 : 31);
result = 31 * result + (isLong ? 13 : 31);
result = 31 * result + (isFloat ? 13 : 31);
result = 31 * result + (isNumber ? 13 : 31);
result = 31 * result + (isDouble ? 13 : 31);
result = 31 * result + (isByteArray ? 13 : 31);
result = 31 * result + (isBinary ? 13 : 31);
result = 31 * result + (isBoolean ? 13 : 31);
result = 31 * result + (isDate ? 13 : 31);
result = 31 * result + (isDateTime ? 13 : 31);
result = 31 * result + (isUuid ? 13 : 31);
result = 31 * result + (isEmail ? 13 : 31);
result = 31 * result + (isFreeFormObject ? 13 : 31);
result = 31 * result + (isListContainer ? 13 : 31);
result = 31 * result + (isMapContainer ? 13 : 31);
result = 31 * result + (isFile ? 13 : 31);
result = 31 * result + (isEnum ? 1 : 0);
result = 31 * result + (_enum != null ? _enum.hashCode() : 0);
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
result = 31 * result + (items != null ? items.hashCode() : 0);
result = 31 * result + (mostInnerItems != null ? mostInnerItems.hashCode() : 0);
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
result = 31 * result + (hasValidation ? 13:31);
result = 31 * result + (isNullable ? 13:31);
result = 31 * result + (required ? 13:31);
result = 31 * result + (hasValidation ? 13 : 31);
result = 31 * result + (isNullable ? 13 : 31);
result = 31 * result + (required ? 13 : 31);
result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
result = 31 * result + (exclusiveMaximum ? 13:31);
result = 31 * result + (exclusiveMaximum ? 13 : 31);
result = 31 * result + (minimum != null ? minimum.hashCode() : 0);
result = 31 * result + (exclusiveMinimum ? 13:31);
result = 31 * result + (exclusiveMinimum ? 13 : 31);
result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0);
result = 31 * result + (minLength != null ? minLength.hashCode() : 0);
result = 31 * result + (pattern != null ? pattern.hashCode() : 0);
result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0);
result = 31 * result + (minItems != null ? minItems.hashCode() : 0);
result = 31 * result + (uniqueItems ? 13:31);
result = 31 * result + (uniqueItems ? 13 : 31);
result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0);
return result;
}
Expand Down Expand Up @@ -414,6 +419,7 @@ public java.lang.String toString() {
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
", isEmail=" + isEmail +
", isFreeFormObject=" + isFreeFormObject +
", isListContainer=" + isListContainer +
", isMapContainer=" + isMapContainer +
", isFile=" + isFile +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@

public class CodegenProperty implements Cloneable {
public String baseName, complexType, getter, setter, description, dataType,
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
baseType, containerType, title;
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
baseType, containerType, title;

/** The 'description' string without escape charcters needed by some programming languages/targets */
/**
* The 'description' string without escape charcters needed by some programming languages/targets
*/
public String unescapedDescription;

/**
Expand Down Expand Up @@ -56,7 +58,8 @@ public class CodegenProperty implements Cloneable {
public boolean hasMore, required, secondaryParam;
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
public boolean isPrimitiveType, isModel, isContainer, isNotContainer;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid, isEmail;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
public boolean isEnum;
public boolean isReadOnly;
Expand Down Expand Up @@ -84,7 +87,7 @@ public class CodegenProperty implements Cloneable {
public String xmlNamespace;
public boolean isXmlWrapped = false;

public String getBaseName() {
public String getBaseName() {
return baseName;
}

Expand Down Expand Up @@ -125,9 +128,9 @@ public void setDescription(String description) {
}

/**
* @return dataType
* @deprecated since version 3.0.0, use {@link #getDataType()} instead.<br>
* May be removed with the next major release (4.0)
* @return dataType
*/
@Deprecated
public String getDatatype() {
Expand Down Expand Up @@ -411,8 +414,7 @@ public void setXmlNamespace(String xmlNamespace) {
}

@Override
public int hashCode()
{
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((_enum == null) ? 0 : _enum.hashCode());
Expand All @@ -429,19 +431,19 @@ public int hashCode()
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((title == null) ? 0 : title.hashCode());
result = prime * result + ((example == null) ? 0 : example.hashCode());
result = prime * result + (exclusiveMaximum ? 13:31);
result = prime * result + (exclusiveMinimum ? 13:31);
result = prime * result + (exclusiveMaximum ? 13 : 31);
result = prime * result + (exclusiveMinimum ? 13 : 31);
result = prime * result + ((getter == null) ? 0 : getter.hashCode());
result = prime * result + (hasMore ? 13:31);
result = prime * result + ((hasMoreNonReadOnly ? 13:31));
result = prime * result + ((isContainer ? 13:31));
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 ? 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));
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));
result = prime * result + ((items == null) ? 0 : items.hashCode());
result = prime * result + ((mostInnerItems == null) ? 0 : mostInnerItems.hashCode());
result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode());
Expand All @@ -453,41 +455,42 @@ public int hashCode()
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 ? 13:31));
result = prime * result + ((secondaryParam ? 13:31));
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 ? 13:31));
result = prime * result + ((isString ? 13:31));
result = prime * result + ((isNumeric ? 13:31));
result = prime * result + ((isInteger ? 13:31));
result = prime * result + ((isLong ?13:31));
result = prime * result + ((isNumber ? 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 + ((isFile ? 13:31));
result = prime * result + ((isBoolean ? 13:31));
result = prime * result + ((isDate ? 13:31));
result = prime * result + ((isDateTime ? 13:31));
result = prime * result + ((isUuid ? 13:31));
result = prime * result + ((isEmail ? 13:31));
result = prime * result + ((isMapContainer ? 13:31));
result = prime * result + ((isListContainer ? 13:31));
result = prime * result + ((hasValidation ? 13 : 31));
result = prime * result + ((isString ? 13 : 31));
result = prime * result + ((isNumeric ? 13 : 31));
result = prime * result + ((isInteger ? 13 : 31));
result = prime * result + ((isLong ? 13 : 31));
result = prime * result + ((isNumber ? 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 + ((isFile ? 13 : 31));
result = prime * result + ((isBoolean ? 13 : 31));
result = prime * result + ((isDate ? 13 : 31));
result = prime * result + ((isDateTime ? 13 : 31));
result = prime * result + ((isUuid ? 13 : 31));
result = prime * result + ((isEmail ? 13 : 31));
result = prime * result + ((isFreeFormObject ? 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(discriminatorValue);
result = prime * result + Objects.hashCode(nameInCamelCase);
result = prime * result + Objects.hashCode(nameInSnakeCase);
result = prime * result + Objects.hashCode(enumName);
result = prime * result + ((maxItems == null) ? 0 : maxItems.hashCode());
result = prime * result + ((minItems == null) ? 0 : minItems.hashCode());
result = prime * result + ((isXmlAttribute ? 13:31));
result = prime * result + ((isXmlAttribute ? 13 : 31));
result = prime * result + ((xmlPrefix == null) ? 0 : xmlPrefix.hashCode());
result = prime * result + ((xmlName == null) ? 0 : xmlName.hashCode());
result = prime * result + ((xmlNamespace == null) ? 0 : xmlNamespace.hashCode());
result = prime * result + ((isXmlWrapped ? 13:31));
result = prime * result + ((isXmlWrapped ? 13 : 31));
return result;
}

Expand Down Expand Up @@ -657,6 +660,9 @@ public boolean equals(Object obj) {
if (this.isEmail != other.isEmail) {
return false;
}
if (this.isFreeFormObject != other.isFreeFormObject) {
return false;
}
if (this.isBinary != other.isBinary) {
return false;
}
Expand Down Expand Up @@ -724,7 +730,7 @@ public CodegenProperty clone() {
if (this.mostInnerItems != null) {
cp.mostInnerItems = this.mostInnerItems;
}
if(this.vendorExtensions != null){
if (this.vendorExtensions != null) {
cp.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions);
}
return cp;
Expand Down Expand Up @@ -785,11 +791,12 @@ public java.lang.String toString() {
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
", isEmail=" + isEmail +
", isFreeFormObject=" + isFreeFormObject +
", isListContainer=" + isListContainer +
", isMapContainer=" + isMapContainer +
", isEnum=" + isEnum +
", isReadOnly=" + isReadOnly +
", isWriteOnly=" + isWriteOnly+
", isWriteOnly=" + isWriteOnly +
", isNullable=" + isNullable +
", _enum=" + _enum +
", allowableValues=" + allowableValues +
Expand Down
Loading

0 comments on commit 5aa1da7

Please sign in to comment.