Skip to content

Commit

Permalink
Merge pull request #173 from swagger-api/fix-additional-props
Browse files Browse the repository at this point in the history
fix handling of additionalProperties as Boolean
  • Loading branch information
frantuma committed Sep 20, 2018
2 parents d06e709 + d9a7a8a commit 37f07be
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ else if (Parameter.StyleEnum.SPACEDELIMITED.equals(queryParameter.getStyle())) {
* @return string presentation of the instantiation type of the property
*/
public String toInstantiationType(Schema property) {
if (property instanceof MapSchema || property.getAdditionalProperties() != null) {
if (property instanceof MapSchema || (property.getAdditionalProperties() != null && (property.getAdditionalProperties() instanceof Schema))) {
Schema additionalProperties = (Schema) property.getAdditionalProperties();
String type = additionalProperties.getType();
if (null == type) {
Expand Down Expand Up @@ -1053,7 +1053,7 @@ private static String getTypeOfSchema(Schema schema) {
return "string";
} else {
if (schema != null) {
if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && schema.getAdditionalProperties() != null) {
if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && schema.getAdditionalProperties() != null && (schema.getAdditionalProperties() instanceof Schema)) {
return "map";
} else {
return schema.getType();
Expand Down Expand Up @@ -1331,7 +1331,7 @@ else if (schema instanceof ComposedSchema) {
codegenModel.allowableValues = new HashMap<String, Object>();
codegenModel.allowableValues.put("values", schema.getEnum());
}
if (schema.getAdditionalProperties() != null) {
if (schema.getAdditionalProperties() != null && (schema.getAdditionalProperties() instanceof Schema)) {
addAdditionPropertiesToCodeGenModel(codegenModel, schema);
}
addVars(codegenModel, schema.getProperties(), schema.getRequired());
Expand Down Expand Up @@ -1649,7 +1649,7 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
Schema items = ((ArraySchema) propertySchema).getItems();
CodegenProperty innerCodegenProperty = fromProperty(itemName, items);
updatePropertyForArray(codegenProperty, innerCodegenProperty);
} else if (propertySchema instanceof MapSchema || propertySchema.getAdditionalProperties() != null) {
} else if (propertySchema instanceof MapSchema || ((propertySchema.getAdditionalProperties() != null && (propertySchema.getAdditionalProperties() instanceof Schema)))) {

codegenProperty.getVendorExtensions().put(CodegenConstants.IS_CONTAINER_EXT_NAME, Boolean.TRUE);
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_MAP_CONTAINER_EXT_NAME, Boolean.TRUE);
Expand Down

0 comments on commit 37f07be

Please sign in to comment.