Skip to content

Commit d9a7a8a

Browse files
committed
fix handling of additionalProperties as Boolean
1 parent d06e709 commit d9a7a8a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ else if (Parameter.StyleEnum.SPACEDELIMITED.equals(queryParameter.getStyle())) {
927927
* @return string presentation of the instantiation type of the property
928928
*/
929929
public String toInstantiationType(Schema property) {
930-
if (property instanceof MapSchema || property.getAdditionalProperties() != null) {
930+
if (property instanceof MapSchema || (property.getAdditionalProperties() != null && (property.getAdditionalProperties() instanceof Schema))) {
931931
Schema additionalProperties = (Schema) property.getAdditionalProperties();
932932
String type = additionalProperties.getType();
933933
if (null == type) {
@@ -1053,7 +1053,7 @@ private static String getTypeOfSchema(Schema schema) {
10531053
return "string";
10541054
} else {
10551055
if (schema != null) {
1056-
if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && schema.getAdditionalProperties() != null) {
1056+
if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && schema.getAdditionalProperties() != null && (schema.getAdditionalProperties() instanceof Schema)) {
10571057
return "map";
10581058
} else {
10591059
return schema.getType();
@@ -1331,7 +1331,7 @@ else if (schema instanceof ComposedSchema) {
13311331
codegenModel.allowableValues = new HashMap<String, Object>();
13321332
codegenModel.allowableValues.put("values", schema.getEnum());
13331333
}
1334-
if (schema.getAdditionalProperties() != null) {
1334+
if (schema.getAdditionalProperties() != null && (schema.getAdditionalProperties() instanceof Schema)) {
13351335
addAdditionPropertiesToCodeGenModel(codegenModel, schema);
13361336
}
13371337
addVars(codegenModel, schema.getProperties(), schema.getRequired());
@@ -1649,7 +1649,7 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
16491649
Schema items = ((ArraySchema) propertySchema).getItems();
16501650
CodegenProperty innerCodegenProperty = fromProperty(itemName, items);
16511651
updatePropertyForArray(codegenProperty, innerCodegenProperty);
1652-
} else if (propertySchema instanceof MapSchema || propertySchema.getAdditionalProperties() != null) {
1652+
} else if (propertySchema instanceof MapSchema || ((propertySchema.getAdditionalProperties() != null && (propertySchema.getAdditionalProperties() instanceof Schema)))) {
16531653

16541654
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_CONTAINER_EXT_NAME, Boolean.TRUE);
16551655
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_MAP_CONTAINER_EXT_NAME, Boolean.TRUE);

0 commit comments

Comments
 (0)