From 92f4d8e3233c3c74c8915aa2f5973ae59bf786a1 Mon Sep 17 00:00:00 2001 From: frantuma Date: Tue, 15 Nov 2022 15:46:36 +0100 Subject: [PATCH] update support for boolean additionalProperties --- .../io/swagger/parser/util/SwaggerDeserializer.java | 11 ++++++++++- pom.xml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java b/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java index fa2842d93c..956ff379c7 100644 --- a/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java +++ b/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java @@ -6,6 +6,7 @@ import io.swagger.models.auth.*; import io.swagger.models.parameters.*; import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanValueProperty; import io.swagger.models.properties.Property; import io.swagger.models.properties.PropertyBuilder; import io.swagger.util.Json; @@ -769,6 +770,9 @@ public Model definition(ObjectNode node, String location, ParseResult result) { result.missing(location, "empty schema"); return null; } + if (node.isBoolean()) { + return new BooleanValueModel(node.asBoolean()); + } if (node.get("$ref") != null) { return refModel(node, location, result); } @@ -804,7 +808,7 @@ public Model definition(ObjectNode node, String location, ParseResult result) { am.setUniqueItems(uniqueItems); } - // add xml specific information if available + // add xml specific information if available JsonNode xml = node.get("xml"); if (xml != null) { am.setXml(Json.mapper().convertValue(xml, Xml.class)); @@ -826,6 +830,8 @@ public Model definition(ObjectNode node, String location, ParseResult result) { JsonNode ap = node.get("additionalProperties"); if (ap != null && ap.getNodeType().equals(JsonNodeType.OBJECT)) { impl.setAdditionalProperties(Json.mapper().convertValue(ap, Property.class)); + } else if (ap != null && ap.isBoolean()) { + impl.setAdditionalProperties(new BooleanValueProperty(ap.asBoolean())); } value = getString("default", node, false, location, result); @@ -1092,6 +1098,9 @@ public Map properties(ObjectNode node, String location, ParseR public Property property(ObjectNode node, String location, ParseResult result) { if (node != null) { + if (node.isBoolean()) { + return new BooleanValueProperty(node.asBoolean()); + } if (node.get("type") == null) { // may have an enum where type can be inferred JsonNode enumNode = node.get("enum"); diff --git a/pom.xml b/pom.xml index fbc6b6ed26..03889e31a7 100644 --- a/pom.xml +++ b/pom.xml @@ -394,7 +394,7 @@ 2.11.0 1.33 1.7.28 - 1.6.8 + 1.6.9 4.13.1 6.9.6 1.19