Skip to content

Commit

Permalink
Better "Any Type" support (#6091)
Browse files Browse the repository at this point in the history
* better anytype support

* add tests for any type

* fix test with any_value

* fix tests

* fix case additionalProperties: {}

* test with CI

* remove check in map schema

* Revert "remove check in map schema"

This reverts commit e016c41.

* fix tests, comment out map schema fix

* fix tests

* fix tests with correct codegen model

* fix tests

* fix tests for map of any type

* fix array of any type

* fix array of any type

* update samples, remove log

* add typemapping to go, python
  • Loading branch information
wing328 committed Apr 30, 2020
1 parent cc623ba commit 3bbaedd
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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, isByteArray, isBinary,
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject;
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType;
public boolean isListContainer, isMapContainer;
public boolean isFile;
public boolean isEnum;
Expand Down Expand Up @@ -178,6 +178,7 @@ public CodegenParameter copy() {
output.isUri = this.isUri;
output.isEmail = this.isEmail;
output.isFreeFormObject = this.isFreeFormObject;
output.isAnyType = this.isAnyType;
output.isListContainer = this.isListContainer;
output.isMapContainer = this.isMapContainer;
output.isExplode = this.isExplode;
Expand All @@ -188,7 +189,7 @@ public CodegenParameter copy() {

@Override
public int hashCode() {
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, hasMore, isContainer, secondaryParam, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isListContainer, isMapContainer, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), multipleOf);
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, hasMore, isContainer, secondaryParam, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isListContainer, isMapContainer, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), multipleOf);
}

@Override
Expand Down Expand Up @@ -225,6 +226,7 @@ public boolean equals(Object o) {
isUri == that.isUri &&
isEmail == that.isEmail &&
isFreeFormObject == that.isFreeFormObject &&
isAnyType == that.isAnyType &&
isListContainer == that.isListContainer &&
isMapContainer == that.isMapContainer &&
isFile == that.isFile &&
Expand Down Expand Up @@ -312,6 +314,7 @@ public String toString() {
sb.append(", isUri=").append(isUri);
sb.append(", isEmail=").append(isEmail);
sb.append(", isFreeFormObject=").append(isFreeFormObject);
sb.append(", isAnyType=").append(isAnyType);
sb.append(", isListContainer=").append(isListContainer);
sb.append(", isMapContainer=").append(isMapContainer);
sb.append(", isFile=").append(isFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public boolean isEmail;
public boolean isModel;
public boolean isFreeFormObject;
public boolean isAnyType;
public boolean isDefault;
public boolean simpleType;
public boolean primitiveType;
Expand Down Expand Up @@ -77,7 +78,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public int hashCode() {
return Objects.hash(headers, code, message, hasMore, examples, dataType, baseType, containerType, hasHeaders,
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBoolean, isDate,
isDateTime, isUuid, isEmail, isModel, isFreeFormObject, isDefault, simpleType, primitiveType,
isDateTime, isUuid, isEmail, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
isMapContainer, isListContainer, isBinary, isFile, schema, jsonSchema, vendorExtensions,
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern());
Expand Down Expand Up @@ -105,6 +106,7 @@ public boolean equals(Object o) {
isEmail == that.isEmail &&
isModel == that.isModel &&
isFreeFormObject == that.isFreeFormObject &&
isAnyType == that.isAnyType &&
isDefault == that.isDefault &&
simpleType == that.simpleType &&
primitiveType == that.primitiveType &&
Expand Down Expand Up @@ -295,6 +297,7 @@ public String toString() {
sb.append(", isEmail=").append(isEmail);
sb.append(", isModel=").append(isModel);
sb.append(", isFreeFormObject=").append(isFreeFormObject);
sb.append(", isAnyType=").append(isAnyType);
sb.append(", isDefault=").append(isDefault);
sb.append(", simpleType=").append(simpleType);
sb.append(", primitiveType=").append(primitiveType);
Expand Down
Loading

0 comments on commit 3bbaedd

Please sign in to comment.