review comments adaption
@@ -714,6 +714,11 @@ public class OpenAPIDeserializer {
return getString(key, node, required, location, result, null);
}
+ public String getStringWithDefaultValueSet(String key, ObjectNode node, boolean required, String location, ParseResult result) {
+
+ return getString(key, node, required, location, result, null);
+ }
+
public Set<String> getKeys(ObjectNode node) {
Set<String> keys = new LinkedHashSet<>();
if (node == null) {
@@ -1259,6 +1264,23 @@ public class OpenAPIDeserializer {
return value;
}
+ public Boolean getBooleanWithDefaultValue(String key, ObjectNode node, String location) {
+ Boolean value = null;
+ JsonNode v = node.get(key);
+ if (node == null || v == null) {
+ return false;
+ } else {
+ if (v.getNodeType().equals(JsonNodeType.BOOLEAN)) {
+ value = v.asBoolean();
+ } else if (v.getNodeType().equals(JsonNodeType.STRING)) {
+ String stringValue = v.textValue();
+ return Boolean.parseBoolean(stringValue);
+ }
+ }
+ return value;
+ }
+
+
public BigDecimal getBigDecimal(String key, ObjectNode node, boolean required, String location, ParseResult result) {
BigDecimal value = null;
JsonNode v = node.get(key);
@@ -1408,7 +1430,7 @@ public class OpenAPIDeserializer {
parameter.setDescription(value);
}
- Boolean required = getBoolean("required", obj, false, location, result);
+ Boolean required = getBooleanWithDefaultValue("required", obj, location);
if (required != null) {
parameter.setRequired(required);
}else {
@@ -2195,14 +2217,11 @@ public class OpenAPIDeserializer {
schema.setExample(example);
}
- bool = getBoolean("deprecated", node, false, location, result);
-
+ bool = getBooleanWithDefaultValue("deprecated", node, location);
if(bool != null){
schema.setDeprecated(bool);
}
- else {
- schema.setDeprecated(false);
- }
+
Map <String,Object> extensions = getExtensions(node);
if(extensions != null && extensions.size() > 0) {
@@ -2514,7 +2533,7 @@ public class OpenAPIDeserializer {
operation.setCallbacks(callbacks);
}
- Boolean deprecated = getBoolean("deprecated", obj, false, location, result);
+ Boolean deprecated = getBooleanWithDefaultValue("deprecated", obj, location);
if (deprecated != null) {
operation.setDeprecated(deprecated);
}
