@@ -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 ;
@@ -1402,6 +1407,9 @@ public Map<String, Parameter> getParameters(ObjectNode obj, String location, Par
1402
1407
if (parameterObj != null ) {
1403
1408
parameter = getParameter (parameterObj , String .format ("%s.%s" , location , parameterName ), result );
1404
1409
if (parameter != null ) {
1410
+ if (PATH_PARAMETER .equalsIgnoreCase (parameter .getIn ()) && Boolean .FALSE .equals (parameter .getRequired ())){
1411
+ result .warning (location , "For path parameter " + parameterName + " the required value should be true" );
1412
+ }
1405
1413
parameters .put (parameterName , parameter );
1406
1414
}
1407
1415
}
@@ -1442,7 +1450,7 @@ public List<Parameter> getParameterList(ArrayNode obj, String location, ParseRes
1442
1450
});
1443
1451
return parameters ;
1444
1452
}
1445
-
1453
+
1446
1454
private Parameter getParameterDefinition (Parameter parameter ) {
1447
1455
if (parameter .get$ref () == null ) {
1448
1456
return parameter ;
@@ -1452,7 +1460,7 @@ private Parameter getParameterDefinition(Parameter parameter) {
1452
1460
.map (Components ::getParameters )
1453
1461
.map (parameters -> parameters .get (parameterSchemaName ))
1454
1462
.orElse (parameter );
1455
-
1463
+
1456
1464
}
1457
1465
1458
1466
public Parameter getParameter (ObjectNode obj , String location , ParseResult result ) {
@@ -1556,7 +1564,7 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
1556
1564
} else {
1557
1565
parameter .setExplode (Boolean .FALSE );
1558
1566
}
1559
-
1567
+
1560
1568
1561
1569
ObjectNode parameterObject = getObject ("schema" ,obj ,false ,location ,result );
1562
1570
if (parameterObject != null ) {
@@ -1801,7 +1809,7 @@ public SecurityScheme getSecurityScheme(ObjectNode node, String location, ParseR
1801
1809
1802
1810
boolean descriptionRequired , bearerFormatRequired , nameRequired , inRequired , schemeRequired , flowsRequired , openIdConnectRequired ;
1803
1811
descriptionRequired = bearerFormatRequired = nameRequired = inRequired = schemeRequired = flowsRequired = openIdConnectRequired = false ;
1804
-
1812
+
1805
1813
String value = getString ("type" , node , true , location , result );
1806
1814
if (StringUtils .isNotBlank (value )) {
1807
1815
if (SecurityScheme .Type .APIKEY .toString ().equals (value )) {
@@ -1939,7 +1947,7 @@ public OAuthFlow getOAuthFlow(String oAuthFlowType, ObjectNode node, String loca
1939
1947
authorizationUrlRequired = tokenUrlRequired =true ;
1940
1948
break ;
1941
1949
}
1942
-
1950
+
1943
1951
String value = getString ("authorizationUrl" , node , authorizationUrlRequired , location , result );
1944
1952
if (StringUtils .isNotBlank (value )) {
1945
1953
oAuthFlow .setAuthorizationUrl (value );
@@ -2434,7 +2442,7 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
2434
2442
* Throws a ParseException if no applicable object can be recognized.
2435
2443
*/
2436
2444
private Object getDecodedObject ( Schema schema , String objectString ) throws ParseException {
2437
- Object object =
2445
+ Object object =
2438
2446
objectString == null ?
2439
2447
null :
2440
2448
@@ -2471,7 +2479,7 @@ private OffsetDateTime toDateTime(String dateString) {
2471
2479
2472
2480
return dateTime ;
2473
2481
}
2474
-
2482
+
2475
2483
2476
2484
/**
2477
2485
* Returns the Date represented by the given RFC3339 full-date string.
@@ -2499,15 +2507,15 @@ private Date toDate( String dateString) {
2499
2507
2500
2508
return date ;
2501
2509
}
2502
-
2510
+
2503
2511
2504
2512
/**
2505
2513
* Returns the byte array represented by the given base64-encoded string.
2506
2514
* Returns null if this string is not a valid base64 encoding.
2507
2515
*/
2508
2516
private byte [] toBytes ( String byteString ) {
2509
2517
byte [] bytes ;
2510
-
2518
+
2511
2519
try {
2512
2520
bytes = Base64 .getDecoder ().decode ( byteString );
2513
2521
}
@@ -3032,11 +3040,11 @@ public void extra(String location, String key, JsonNode value) {
3032
3040
public void missing (String location , String key ) {
3033
3041
missing .add (new Location (location , key ));
3034
3042
}
3035
-
3043
+
3036
3044
public void warning (String location , String key ) {
3037
3045
warnings .add (new Location (location , key ));
3038
3046
}
3039
-
3047
+
3040
3048
public void unique (String location , String key ) {
3041
3049
unique .add (new Location (location , key ));
3042
3050
0 commit comments