@@ -110,11 +110,11 @@ public class OpenAPIDeserializer {
110
110
public SwaggerParseResult deserialize (JsonNode rootNode ) {
111
111
return deserialize (rootNode , null );
112
112
}
113
-
113
+
114
114
public SwaggerParseResult deserialize (JsonNode rootNode , String path ) {
115
115
SwaggerParseResult result = new SwaggerParseResult ();
116
116
try {
117
-
117
+
118
118
ParseResult rootParse = new ParseResult ();
119
119
OpenAPI api = parseRoot (rootNode , rootParse , path );
120
120
result .setOpenAPI (api );
@@ -389,7 +389,7 @@ public List<Server> getServersList(ArrayNode obj, String location, ParseResult r
389
389
}
390
390
return servers ;
391
391
}
392
-
392
+
393
393
public List <Server > getServersList (ArrayNode obj , String location , ParseResult result ) {
394
394
return getServersList (obj , location , result , null );
395
395
}
@@ -454,7 +454,7 @@ public Server getServer(ObjectNode obj, String location, ParseResult result, Str
454
454
455
455
return server ;
456
456
}
457
-
457
+
458
458
boolean isValidURL (String urlString ){
459
459
try {
460
460
URL url = new URL (urlString );
@@ -560,6 +560,11 @@ public Paths getPaths(ObjectNode obj, String location, ParseResult result) {
560
560
if (!definedInPathLevel ) {
561
561
List <Operation > operationsInAPath = getAllOperationsInAPath (pathObj );
562
562
operationsInAPath .forEach (operation -> {
563
+ operation .getParameters ().forEach (parameter -> {
564
+ if (PATH_PARAMETER .equalsIgnoreCase (parameter .getIn ()) && Boolean .FALSE .equals (parameter .getRequired ())){
565
+ result .warning (location , "For path parameter " + parameter .getName () + " the required value should be true" );
566
+ }
567
+ });
563
568
if (!isPathParamDefined (pathParam , operation .getParameters ())) {
564
569
result .warning (location + ".'" + pathName + "'" ," Declared path parameter " + pathParam + " needs to be defined as a path parameter in path or operation level" );
565
570
return ;
@@ -1408,6 +1413,9 @@ public Map<String, Parameter> getParameters(ObjectNode obj, String location, Par
1408
1413
if (parameterObj != null ) {
1409
1414
parameter = getParameter (parameterObj , String .format ("%s.%s" , location , parameterName ), result );
1410
1415
if (parameter != null ) {
1416
+ if (PATH_PARAMETER .equalsIgnoreCase (parameter .getIn ()) && Boolean .FALSE .equals (parameter .getRequired ())){
1417
+ result .warning (location , "For path parameter " + parameterName + " the required value should be true" );
1418
+ }
1411
1419
parameters .put (parameterName , parameter );
1412
1420
}
1413
1421
}
@@ -1448,7 +1456,7 @@ public List<Parameter> getParameterList(ArrayNode obj, String location, ParseRes
1448
1456
});
1449
1457
return parameters ;
1450
1458
}
1451
-
1459
+
1452
1460
private Parameter getParameterDefinition (Parameter parameter ) {
1453
1461
if (parameter .get$ref () == null ) {
1454
1462
return parameter ;
@@ -1458,7 +1466,7 @@ private Parameter getParameterDefinition(Parameter parameter) {
1458
1466
.map (Components ::getParameters )
1459
1467
.map (parameters -> parameters .get (parameterSchemaName ))
1460
1468
.orElse (parameter );
1461
-
1469
+
1462
1470
}
1463
1471
1464
1472
public Parameter getParameter (ObjectNode obj , String location , ParseResult result ) {
@@ -1562,7 +1570,7 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
1562
1570
} else {
1563
1571
parameter .setExplode (Boolean .FALSE );
1564
1572
}
1565
-
1573
+
1566
1574
1567
1575
ObjectNode parameterObject = getObject ("schema" ,obj ,false ,location ,result );
1568
1576
if (parameterObject != null ) {
@@ -1811,7 +1819,7 @@ public SecurityScheme getSecurityScheme(ObjectNode node, String location, ParseR
1811
1819
1812
1820
boolean descriptionRequired , bearerFormatRequired , nameRequired , inRequired , schemeRequired , flowsRequired , openIdConnectRequired ;
1813
1821
descriptionRequired = bearerFormatRequired = nameRequired = inRequired = schemeRequired = flowsRequired = openIdConnectRequired = false ;
1814
-
1822
+
1815
1823
String value = getString ("type" , node , true , location , result );
1816
1824
if (StringUtils .isNotBlank (value )) {
1817
1825
if (SecurityScheme .Type .APIKEY .toString ().equals (value )) {
@@ -1949,7 +1957,7 @@ public OAuthFlow getOAuthFlow(String oAuthFlowType, ObjectNode node, String loca
1949
1957
authorizationUrlRequired = tokenUrlRequired =true ;
1950
1958
break ;
1951
1959
}
1952
-
1960
+
1953
1961
String value = getString ("authorizationUrl" , node , authorizationUrlRequired , location , result );
1954
1962
if (StringUtils .isNotBlank (value )) {
1955
1963
oAuthFlow .setAuthorizationUrl (value );
@@ -2446,7 +2454,7 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
2446
2454
* Throws a ParseException if no applicable object can be recognized.
2447
2455
*/
2448
2456
private Object getDecodedObject ( Schema schema , String objectString ) throws ParseException {
2449
- Object object =
2457
+ Object object =
2450
2458
objectString == null ?
2451
2459
null :
2452
2460
@@ -2483,7 +2491,7 @@ private OffsetDateTime toDateTime(String dateString) {
2483
2491
2484
2492
return dateTime ;
2485
2493
}
2486
-
2494
+
2487
2495
2488
2496
/**
2489
2497
* Returns the Date represented by the given RFC3339 full-date string.
@@ -2511,15 +2519,15 @@ private Date toDate( String dateString) {
2511
2519
2512
2520
return date ;
2513
2521
}
2514
-
2522
+
2515
2523
2516
2524
/**
2517
2525
* Returns the byte array represented by the given base64-encoded string.
2518
2526
* Returns null if this string is not a valid base64 encoding.
2519
2527
*/
2520
2528
private byte [] toBytes ( String byteString ) {
2521
2529
byte [] bytes ;
2522
-
2530
+
2523
2531
try {
2524
2532
bytes = Base64 .getDecoder ().decode ( byteString );
2525
2533
}
@@ -3050,11 +3058,11 @@ public void extra(String location, String key, JsonNode value) {
3050
3058
public void missing (String location , String key ) {
3051
3059
missing .add (new Location (location , key ));
3052
3060
}
3053
-
3061
+
3054
3062
public void warning (String location , String key ) {
3055
3063
warnings .add (new Location (location , key ));
3056
3064
}
3057
-
3065
+
3058
3066
public void unique (String location , String key ) {
3059
3067
unique .add (new Location (location , key ));
3060
3068
0 commit comments