diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index eba888db66..4af2ce13da 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -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) { @@ -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(); @@ -1331,7 +1331,7 @@ else if (schema instanceof ComposedSchema) { codegenModel.allowableValues = new HashMap(); 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()); @@ -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);