@@ -246,17 +246,17 @@ public Components getComponents(ObjectNode obj, String location, ParseResult res
246
246
247
247
ObjectNode node = getObject ("schemas" ,obj ,false , location ,result );
248
248
if (node != null ) {
249
- components .setSchemas (getSchemas (node ,String .format ("%s.%s" , location , "schemas" ),result ));
249
+ components .setSchemas (getSchemas (node ,String .format ("%s.%s" , location , "schemas" ),result , true ));
250
250
}
251
251
252
252
node = getObject ("responses" ,obj ,false , location ,result );
253
253
if (node != null ) {
254
- components .setResponses (getResponses (node , String .format ("%s.%s" , location , "responses" ),result ));
254
+ components .setResponses (getResponses (node , String .format ("%s.%s" , location , "responses" ),result , true ));
255
255
}
256
256
257
257
node = getObject ("parameters" ,obj ,false , location ,result );
258
258
if (node != null ) {
259
- components .setParameters (getParameters (node , String .format ("%s.%s" , location , "parameters" ),result ));
259
+ components .setParameters (getParameters (node , String .format ("%s.%s" , location , "parameters" ),result , true ));
260
260
}
261
261
node = getObject ("examples" ,obj ,false ,location ,result );
262
262
if (node != null ) {
@@ -265,27 +265,27 @@ public Components getComponents(ObjectNode obj, String location, ParseResult res
265
265
266
266
node = getObject ("requestBodies" ,obj ,false ,location ,result );
267
267
if (node != null ) {
268
- components .setRequestBodies (getRequestBodies (node , String .format ("%s.%s" , location , "requestBodies" ),result ));
268
+ components .setRequestBodies (getRequestBodies (node , String .format ("%s.%s" , location , "requestBodies" ),result , true ));
269
269
}
270
270
271
271
node = getObject ("headers" ,obj ,false ,location ,result );
272
272
if (node != null ) {
273
- components .setHeaders (getHeaders (node , String .format ("%s.%s" , location , "headers" ),result ));
273
+ components .setHeaders (getHeaders (node , String .format ("%s.%s" , location , "headers" ),result , true ));
274
274
}
275
275
276
276
node = getObject ("securitySchemes" ,obj ,false ,location ,result );
277
277
if (node != null ) {
278
- components .setSecuritySchemes (getSecuritySchemes (node , String .format ("%s.%s" , location , "securitySchemes" ),result ));
278
+ components .setSecuritySchemes (getSecuritySchemes (node , String .format ("%s.%s" , location , "securitySchemes" ),result , true ));
279
279
}
280
280
281
281
node = getObject ("links" ,obj ,false ,location ,result );
282
282
if (node != null ) {
283
- components .setLinks (getLinks (node , String .format ("%s.%s" , location , "links" ),result ));
283
+ components .setLinks (getLinks (node , String .format ("%s.%s" , location , "links" ),result , true ));
284
284
}
285
285
286
286
node = getObject ("callbacks" ,obj ,false ,location ,result );
287
287
if (node != null ) {
288
- components .setCallbacks (getCallbacks (node , String .format ("%s.%s" , location , "callbacks" ),result ));
288
+ components .setCallbacks (getCallbacks (node , String .format ("%s.%s" , location , "callbacks" ),result , true ));
289
289
}
290
290
components .setExtensions (new LinkedHashMap <>());
291
291
@@ -1065,7 +1065,7 @@ public Encoding getEncoding(ObjectNode node, String location, ParseResult result
1065
1065
}
1066
1066
ObjectNode headersObject = getObject ("headers" , node , false , location , result );
1067
1067
if (headersObject != null ){
1068
- encoding .setHeaders (getHeaders (headersObject , location , result ));
1068
+ encoding .setHeaders (getHeaders (headersObject , location , result , false ));
1069
1069
}
1070
1070
1071
1071
Map <String ,Object > extensions = getExtensions (node );
@@ -1083,7 +1083,7 @@ public Encoding getEncoding(ObjectNode node, String location, ParseResult result
1083
1083
return encoding ;
1084
1084
}
1085
1085
1086
- public Map <String , Link > getLinks (ObjectNode obj , String location , ParseResult result ) {
1086
+ public Map <String , Link > getLinks (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1087
1087
if (obj == null ) {
1088
1088
return null ;
1089
1089
}
@@ -1092,9 +1092,11 @@ public Map<String, Link> getLinks(ObjectNode obj, String location, ParseResult r
1092
1092
1093
1093
Set <String > linkKeys = getKeys (obj );
1094
1094
for (String linkName : linkKeys ) {
1095
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1096
- linkName )) {
1097
- result .warning (location , "Link name " + linkName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1095
+ if (underComponents ) {
1096
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1097
+ linkName )) {
1098
+ result .warning (location , "Link name " + linkName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1099
+ }
1098
1100
}
1099
1101
1100
1102
JsonNode linkValue = obj .get (linkName );
@@ -1158,7 +1160,7 @@ public Link getLink(ObjectNode linkNode, String location, ParseResult result) {
1158
1160
1159
1161
ObjectNode headerObject = getObject ("headers" ,linkNode ,false ,location ,result );
1160
1162
if (headerObject != null ) {
1161
- link .setHeaders (getHeaders (headerObject , location , result ));
1163
+ link .setHeaders (getHeaders (headerObject , location , result , false ));
1162
1164
}
1163
1165
1164
1166
ObjectNode serverObject = getObject ("server" ,linkNode ,false ,location ,result );
@@ -1199,16 +1201,18 @@ private Map<String,String> getLinkParameters(ObjectNode parametersObject, String
1199
1201
return linkParameters ;
1200
1202
}
1201
1203
1202
- public Map <String ,Callback > getCallbacks (ObjectNode node , String location , ParseResult result ){
1204
+ public Map <String ,Callback > getCallbacks (ObjectNode node , String location , ParseResult result , boolean underComponents ){
1203
1205
if (node == null ) {
1204
1206
return null ;
1205
1207
}
1206
1208
Map <String , Callback > callbacks = new LinkedHashMap <>();
1207
1209
Set <String > keys = getKeys (node );
1208
1210
for (String key : keys ) {
1209
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1210
- key )) {
1211
- result .warning (location , "Callback key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1211
+ if (underComponents ) {
1212
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1213
+ key )) {
1214
+ result .warning (location , "Callback key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1215
+ }
1212
1216
}
1213
1217
Callback callback = getCallback ((ObjectNode ) node .get (key ), location , result );
1214
1218
if (callback != null ) {
@@ -1381,7 +1385,7 @@ else if(!v.isValueNode()) {
1381
1385
return value ;
1382
1386
}
1383
1387
1384
- public Map <String , Parameter > getParameters (ObjectNode obj , String location , ParseResult result ) {
1388
+ public Map <String , Parameter > getParameters (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1385
1389
if (obj == null ) {
1386
1390
return null ;
1387
1391
}
@@ -1391,9 +1395,11 @@ public Map<String, Parameter> getParameters(ObjectNode obj, String location, Par
1391
1395
1392
1396
Set <String > parameterKeys = getKeys (obj );
1393
1397
for (String parameterName : parameterKeys ) {
1394
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1395
- parameterName )) {
1396
- result .warning (location , "Parameter name " + parameterName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1398
+ if (underComponents ) {
1399
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1400
+ parameterName )) {
1401
+ result .warning (location , "Parameter name " + parameterName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1402
+ }
1397
1403
}
1398
1404
1399
1405
JsonNode parameterValue = obj .get (parameterName );
@@ -1599,17 +1605,19 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
1599
1605
}
1600
1606
1601
1607
1602
- public Map <String , Header > getHeaders (ObjectNode obj , String location , ParseResult result ) {
1608
+ public Map <String , Header > getHeaders (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1603
1609
if (obj == null ) {
1604
1610
return null ;
1605
1611
}
1606
1612
Map <String , Header > headers = new LinkedHashMap <>();
1607
1613
1608
1614
Set <String > headerKeys = getKeys (obj );
1609
1615
for (String headerName : headerKeys ) {
1610
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1611
- headerName )) {
1612
- result .warning (location , "Header name " + headerName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1616
+ if (underComponents ) {
1617
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1618
+ headerName )) {
1619
+ result .warning (location , "Header name " + headerName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1620
+ }
1613
1621
}
1614
1622
JsonNode headerValue = obj .get (headerName );
1615
1623
if (!headerValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
@@ -1750,17 +1758,19 @@ public Object getAnyExample(String nodeKey,ObjectNode node, String location, Par
1750
1758
return null ;
1751
1759
}
1752
1760
1753
- public Map <String , SecurityScheme > getSecuritySchemes (ObjectNode obj , String location , ParseResult result ) {
1761
+ public Map <String , SecurityScheme > getSecuritySchemes (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1754
1762
if (obj == null ) {
1755
1763
return null ;
1756
1764
}
1757
1765
Map <String , SecurityScheme > securitySchemes = new LinkedHashMap <>();
1758
1766
1759
1767
Set <String > securitySchemeKeys = getKeys (obj );
1760
1768
for (String securitySchemeName : securitySchemeKeys ) {
1761
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1762
- securitySchemeName )) {
1763
- result .warning (location , "SecurityScheme name " + securitySchemeName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1769
+ if (underComponents ) {
1770
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1771
+ securitySchemeName )) {
1772
+ result .warning (location , "SecurityScheme name " + securitySchemeName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1773
+ }
1764
1774
}
1765
1775
JsonNode securitySchemeValue = obj .get (securitySchemeName );
1766
1776
if (!securitySchemeValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
@@ -1982,17 +1992,19 @@ public OAuthFlow getOAuthFlow(String oAuthFlowType, ObjectNode node, String loca
1982
1992
return oAuthFlow ;
1983
1993
}
1984
1994
1985
- public Map <String , Schema > getSchemas (ObjectNode obj , String location , ParseResult result ) {
1995
+ public Map <String , Schema > getSchemas (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1986
1996
if (obj == null ) {
1987
1997
return null ;
1988
1998
}
1989
1999
Map <String , Schema > schemas = new LinkedHashMap <>();
1990
2000
1991
2001
Set <String > schemaKeys = getKeys (obj );
1992
2002
for (String schemaName : schemaKeys ) {
1993
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1994
- schemaName )) {
1995
- result .warning (location , "Schema name " + schemaName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2003
+ if (underComponents ) {
2004
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2005
+ schemaName )) {
2006
+ result .warning (location , "Schema name " + schemaName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2007
+ }
1996
2008
}
1997
2009
JsonNode schemaValue = obj .get (schemaName );
1998
2010
if (!schemaValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
@@ -2521,15 +2533,15 @@ private byte[] toBytes( String byteString) {
2521
2533
2522
2534
2523
2535
2524
- public Map <String , Example > getExamples (ObjectNode obj , String location , ParseResult result , boolean UnderComponents ) {
2536
+ public Map <String , Example > getExamples (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
2525
2537
if (obj == null ) {
2526
2538
return null ;
2527
2539
}
2528
2540
Map <String , Example > examples = new LinkedHashMap <>();
2529
2541
2530
2542
Set <String > exampleKeys = getKeys (obj );
2531
2543
for (String exampleName : exampleKeys ) {
2532
- if (UnderComponents ) {
2544
+ if (underComponents ) {
2533
2545
if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2534
2546
exampleName )) {
2535
2547
result .warning (location , "Example name " + exampleName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
@@ -2656,7 +2668,7 @@ public void setStyle(String value, Parameter parameter, String location, ObjectN
2656
2668
}
2657
2669
}
2658
2670
2659
- public ApiResponses getResponses (ObjectNode node , String location , ParseResult result ) {
2671
+ public ApiResponses getResponses (ObjectNode node , String location , ParseResult result , boolean underComponents ) {
2660
2672
if (node == null ) {
2661
2673
return null ;
2662
2674
}
@@ -2665,9 +2677,11 @@ public ApiResponses getResponses(ObjectNode node, String location, ParseResult r
2665
2677
Set <String > keys = getKeys (node );
2666
2678
2667
2679
for (String key : keys ) {
2668
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2669
- key )) {
2670
- result .warning (location , "Response key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2680
+ if (underComponents ) {
2681
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2682
+ key )) {
2683
+ result .warning (location , "Response key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2684
+ }
2671
2685
}
2672
2686
2673
2687
if (key .startsWith ("x-" )) {
@@ -2719,15 +2733,15 @@ public ApiResponse getResponse(ObjectNode node, String location, ParseResult res
2719
2733
2720
2734
ObjectNode headerObject = getObject ("headers" , node , false , location , result );
2721
2735
if (headerObject != null ) {
2722
- Map <String , Header > headers = getHeaders (headerObject , location , result );
2736
+ Map <String , Header > headers = getHeaders (headerObject , location , result , false );
2723
2737
if (headers != null && headers .size () > 0 ) {
2724
2738
apiResponse .setHeaders (headers );
2725
2739
}
2726
2740
}
2727
2741
2728
2742
ObjectNode linksObj = getObject ("links" , node , false , location , result );
2729
2743
if (linksObj != null ) {
2730
- Map <String ,Link > links = getLinks (linksObj , location , result );
2744
+ Map <String ,Link > links = getLinks (linksObj , location , result , false );
2731
2745
if (links != null && links .size () > 0 ) {
2732
2746
apiResponse .setLinks (links );
2733
2747
}
@@ -2813,13 +2827,13 @@ public Operation getOperation(ObjectNode obj, String location, ParseResult resul
2813
2827
}
2814
2828
2815
2829
ObjectNode responsesNode = getObject ("responses" , obj , true , location , result );
2816
- ApiResponses responses = getResponses (responsesNode , String .format ("%s.%s" , location , "responses" ), result );
2830
+ ApiResponses responses = getResponses (responsesNode , String .format ("%s.%s" , location , "responses" ), result , false );
2817
2831
if (responses != null ) {
2818
2832
operation .setResponses (responses );
2819
2833
}
2820
2834
2821
2835
ObjectNode callbacksNode = getObject ("callbacks" , obj , false , location , result );
2822
- Map <String ,Callback > callbacks = getCallbacks (callbacksNode , String .format ("%s.%s" , location , "callbacks" ), result );
2836
+ Map <String ,Callback > callbacks = getCallbacks (callbacksNode , String .format ("%s.%s" , location , "callbacks" ), result , false );
2823
2837
if (callbacks != null ){
2824
2838
operation .setCallbacks (callbacks );
2825
2839
}
@@ -2895,17 +2909,19 @@ public List<SecurityRequirement> getSecurityRequirementsList(ArrayNode nodes, St
2895
2909
2896
2910
}
2897
2911
2898
- public Map <String , RequestBody > getRequestBodies (ObjectNode obj , String location , ParseResult result ) {
2912
+ public Map <String , RequestBody > getRequestBodies (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
2899
2913
if (obj == null ) {
2900
2914
return null ;
2901
2915
}
2902
2916
Map <String , RequestBody > bodies = new LinkedHashMap <>();
2903
2917
2904
2918
Set <String > bodyKeys = getKeys (obj );
2905
2919
for (String bodyName : bodyKeys ) {
2906
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2907
- bodyName )) {
2908
- result .warning (location , "RequestBody name " + bodyName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2920
+ if (underComponents ) {
2921
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2922
+ bodyName )) {
2923
+ result .warning (location , "RequestBody name " + bodyName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2924
+ }
2909
2925
}
2910
2926
JsonNode bodyValue = obj .get (bodyName );
2911
2927
if (!bodyValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
0 commit comments