diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ModelDeserializer.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ModelDeserializer.java index 4159b7cc1e..e480c1a329 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ModelDeserializer.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ModelDeserializer.java @@ -44,7 +44,9 @@ public Schema deserialize(JsonParser jp, DeserializationContext ctxt) schema = deserializeJsonSchema(node); return schema; } - + if (node.isBoolean()) { + return new Schema().booleanSchemaValue(node.booleanValue()); + } List composed = Arrays.asList("allOf", "anyOf", "oneOf"); for (String field: composed) { @@ -98,23 +100,22 @@ private Schema deserializeObjectSchema(JsonNode node) { JsonNode additionalProperties = node.get("additionalProperties"); Schema schema = null; if (additionalProperties != null) { - // try first to convert to Schema, if it fails it must be a boolean - try { - Schema innerSchema = Json.mapper().convertValue(additionalProperties, Schema.class); - ((ObjectNode)node).remove("additionalProperties"); - MapSchema ms = Json.mapper().convertValue(node, MapSchema.class); - ms.setAdditionalProperties(innerSchema); - schema = ms; - } catch (Exception e) { + if (additionalProperties.isBoolean()) { Boolean additionalPropsBoolean = Json.mapper().convertValue(additionalProperties, Boolean.class); + ((ObjectNode)node).remove("additionalProperties"); if (additionalPropsBoolean) { schema = Json.mapper().convertValue(node, MapSchema.class); } else { schema = Json.mapper().convertValue(node, ObjectSchema.class); } schema.setAdditionalProperties(additionalPropsBoolean); + } else { + Schema innerSchema = Json.mapper().convertValue(additionalProperties, Schema.class); + ((ObjectNode)node).remove("additionalProperties"); + MapSchema ms = Json.mapper().convertValue(node, MapSchema.class); + ms.setAdditionalProperties(innerSchema); + schema = ms; } - } else { schema = Json.mapper().convertValue(node, ObjectSchema.class); }