@@ -714,6 +714,11 @@ public String getString(String key, ObjectNode node, boolean required, String lo
714
714
return getString (key , node , required , location , result , null );
715
715
}
716
716
717
+ public String getStringWithDefaultValueSet (String key , ObjectNode node , boolean required , String location , ParseResult result ) {
718
+
719
+ return getString (key , node , required , location , result , null );
720
+ }
721
+
717
722
public Set <String > getKeys (ObjectNode node ) {
718
723
Set <String > keys = new LinkedHashSet <>();
719
724
if (node == null ) {
@@ -1259,6 +1264,23 @@ public Boolean getBoolean(String key, ObjectNode node, boolean required, String
1259
1264
return value ;
1260
1265
}
1261
1266
1267
+ public Boolean getBooleanWithDefaultValue (String key , ObjectNode node , String location ) {
1268
+ Boolean value = null ;
1269
+ JsonNode v = node .get (key );
1270
+ if (node == null || v == null ) {
1271
+ return false ;
1272
+ } else {
1273
+ if (v .getNodeType ().equals (JsonNodeType .BOOLEAN )) {
1274
+ value = v .asBoolean ();
1275
+ } else if (v .getNodeType ().equals (JsonNodeType .STRING )) {
1276
+ String stringValue = v .textValue ();
1277
+ return Boolean .parseBoolean (stringValue );
1278
+ }
1279
+ }
1280
+ return value ;
1281
+ }
1282
+
1283
+
1262
1284
public BigDecimal getBigDecimal (String key , ObjectNode node , boolean required , String location , ParseResult result ) {
1263
1285
BigDecimal value = null ;
1264
1286
JsonNode v = node .get (key );
@@ -1408,7 +1430,7 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
1408
1430
parameter .setDescription (value );
1409
1431
}
1410
1432
1411
- Boolean required = getBoolean ("required" , obj , false , location , result );
1433
+ Boolean required = getBooleanWithDefaultValue ("required" , obj , location );
1412
1434
if (required != null ) {
1413
1435
parameter .setRequired (required );
1414
1436
}else {
@@ -2195,14 +2217,11 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
2195
2217
schema .setExample (example );
2196
2218
}
2197
2219
2198
- bool = getBoolean ("deprecated" , node , false , location , result );
2199
-
2220
+ bool = getBooleanWithDefaultValue ("deprecated" , node , location );
2200
2221
if (bool != null ){
2201
2222
schema .setDeprecated (bool );
2202
2223
}
2203
- else {
2204
- schema .setDeprecated (false );
2205
- }
2224
+
2206
2225
2207
2226
Map <String ,Object > extensions = getExtensions (node );
2208
2227
if (extensions != null && extensions .size () > 0 ) {
@@ -2514,7 +2533,7 @@ public Operation getOperation(ObjectNode obj, String location, ParseResult resul
2514
2533
operation .setCallbacks (callbacks );
2515
2534
}
2516
2535
2517
- Boolean deprecated = getBoolean ("deprecated" , obj , false , location , result );
2536
+ Boolean deprecated = getBooleanWithDefaultValue ("deprecated" , obj , location );
2518
2537
if (deprecated != null ) {
2519
2538
operation .setDeprecated (deprecated );
2520
2539
}
0 commit comments