Skip to content

Commit

Permalink
update support for boolean additionalProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Nov 15, 2022
1 parent cce13ff commit 92f4d8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -1092,6 +1098,9 @@ public Map<String, Property> 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");
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
<commons-io-version>2.11.0</commons-io-version>
<snakeyaml-version>1.33</snakeyaml-version>
<slf4j-version>1.7.28</slf4j-version>
<swagger-core-version>1.6.8</swagger-core-version>
<swagger-core-version>1.6.9</swagger-core-version>
<junit-version>4.13.1</junit-version>
<testng-version>6.9.6</testng-version>
<jmockit-version>1.19</jmockit-version>
Expand Down

0 comments on commit 92f4d8e

Please sign in to comment.