@@ -246,46 +246,46 @@ 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 ) {
263
- components .setExamples (getExamples (node , String .format ("%s.%s" , location , "examples" ),result ));
263
+ components .setExamples (getExamples (node , String .format ("%s.%s" , location , "examples" ),result , true ));
264
264
}
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
@@ -997,7 +997,7 @@ public MediaType getMediaType(ObjectNode contentNode, String location, ParseResu
997
997
998
998
ObjectNode examplesObject = getObject ("examples" ,contentNode ,false ,location ,result );
999
999
if (examplesObject !=null ) {
1000
- mediaType .setExamples (getExamples (examplesObject , String .format ("%s.%s" , location , "examples" ), result ));
1000
+ mediaType .setExamples (getExamples (examplesObject , String .format ("%s.%s" , location , "examples" ), result , false ));
1001
1001
}
1002
1002
1003
1003
Object example = getAnyExample ("example" ,contentNode , location ,result );
@@ -1070,7 +1070,7 @@ public Encoding getEncoding(ObjectNode node, String location, ParseResult result
1070
1070
}
1071
1071
ObjectNode headersObject = getObject ("headers" , node , false , location , result );
1072
1072
if (headersObject != null ){
1073
- encoding .setHeaders (getHeaders (headersObject , location , result ));
1073
+ encoding .setHeaders (getHeaders (headersObject , location , result , false ));
1074
1074
}
1075
1075
1076
1076
Map <String ,Object > extensions = getExtensions (node );
@@ -1088,7 +1088,7 @@ public Encoding getEncoding(ObjectNode node, String location, ParseResult result
1088
1088
return encoding ;
1089
1089
}
1090
1090
1091
- public Map <String , Link > getLinks (ObjectNode obj , String location , ParseResult result ) {
1091
+ public Map <String , Link > getLinks (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1092
1092
if (obj == null ) {
1093
1093
return null ;
1094
1094
}
@@ -1097,9 +1097,11 @@ public Map<String, Link> getLinks(ObjectNode obj, String location, ParseResult r
1097
1097
1098
1098
Set <String > linkKeys = getKeys (obj );
1099
1099
for (String linkName : linkKeys ) {
1100
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1101
- linkName )) {
1102
- result .warning (location , "Link name " + linkName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1100
+ if (underComponents ) {
1101
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1102
+ linkName )) {
1103
+ result .warning (location , "Link name " + linkName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1104
+ }
1103
1105
}
1104
1106
1105
1107
JsonNode linkValue = obj .get (linkName );
@@ -1163,7 +1165,7 @@ public Link getLink(ObjectNode linkNode, String location, ParseResult result) {
1163
1165
1164
1166
ObjectNode headerObject = getObject ("headers" ,linkNode ,false ,location ,result );
1165
1167
if (headerObject != null ) {
1166
- link .setHeaders (getHeaders (headerObject , location , result ));
1168
+ link .setHeaders (getHeaders (headerObject , location , result , false ));
1167
1169
}
1168
1170
1169
1171
ObjectNode serverObject = getObject ("server" ,linkNode ,false ,location ,result );
@@ -1204,16 +1206,18 @@ private Map<String,String> getLinkParameters(ObjectNode parametersObject, String
1204
1206
return linkParameters ;
1205
1207
}
1206
1208
1207
- public Map <String ,Callback > getCallbacks (ObjectNode node , String location , ParseResult result ){
1209
+ public Map <String ,Callback > getCallbacks (ObjectNode node , String location , ParseResult result , boolean underComponents ){
1208
1210
if (node == null ) {
1209
1211
return null ;
1210
1212
}
1211
1213
Map <String , Callback > callbacks = new LinkedHashMap <>();
1212
1214
Set <String > keys = getKeys (node );
1213
1215
for (String key : keys ) {
1214
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1215
- key )) {
1216
- result .warning (location , "Callback key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1216
+ if (underComponents ) {
1217
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1218
+ key )) {
1219
+ result .warning (location , "Callback key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1220
+ }
1217
1221
}
1218
1222
Callback callback = getCallback ((ObjectNode ) node .get (key ), location , result );
1219
1223
if (callback != null ) {
@@ -1386,7 +1390,7 @@ else if(!v.isValueNode()) {
1386
1390
return value ;
1387
1391
}
1388
1392
1389
- public Map <String , Parameter > getParameters (ObjectNode obj , String location , ParseResult result ) {
1393
+ public Map <String , Parameter > getParameters (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1390
1394
if (obj == null ) {
1391
1395
return null ;
1392
1396
}
@@ -1396,9 +1400,11 @@ public Map<String, Parameter> getParameters(ObjectNode obj, String location, Par
1396
1400
1397
1401
Set <String > parameterKeys = getKeys (obj );
1398
1402
for (String parameterName : parameterKeys ) {
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\\ .\\ -_]+$" );
1403
+ if (underComponents ) {
1404
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1405
+ parameterName )) {
1406
+ result .warning (location , "Parameter name " + parameterName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1407
+ }
1402
1408
}
1403
1409
1404
1410
JsonNode parameterValue = obj .get (parameterName );
@@ -1573,7 +1579,7 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
1573
1579
1574
1580
ObjectNode examplesObject = getObject ("examples" ,obj ,false ,location ,result );
1575
1581
if (examplesObject !=null ) {
1576
- parameter .setExamples (getExamples (examplesObject , String .format ("%s.%s" , location , "examples" ), result ));
1582
+ parameter .setExamples (getExamples (examplesObject , String .format ("%s.%s" , location , "examples" ), result , false ));
1577
1583
}
1578
1584
1579
1585
Object example = getAnyExample ("example" , obj , location ,result );
@@ -1607,17 +1613,19 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
1607
1613
}
1608
1614
1609
1615
1610
- public Map <String , Header > getHeaders (ObjectNode obj , String location , ParseResult result ) {
1616
+ public Map <String , Header > getHeaders (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1611
1617
if (obj == null ) {
1612
1618
return null ;
1613
1619
}
1614
1620
Map <String , Header > headers = new LinkedHashMap <>();
1615
1621
1616
1622
Set <String > headerKeys = getKeys (obj );
1617
1623
for (String headerName : headerKeys ) {
1618
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1619
- headerName )) {
1620
- result .warning (location , "Header name " + headerName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1624
+ if (underComponents ) {
1625
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1626
+ headerName )) {
1627
+ result .warning (location , "Header name " + headerName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1628
+ }
1621
1629
}
1622
1630
JsonNode headerValue = obj .get (headerName );
1623
1631
if (!headerValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
@@ -1691,7 +1699,7 @@ public Header getHeader(ObjectNode headerNode, String location, ParseResult resu
1691
1699
1692
1700
ObjectNode examplesObject = getObject ("examples" ,headerNode ,false ,location ,result );
1693
1701
if (examplesObject !=null ) {
1694
- header .setExamples (getExamples (examplesObject , location , result ));
1702
+ header .setExamples (getExamples (examplesObject , location , result , false ));
1695
1703
}
1696
1704
1697
1705
Object example = getAnyExample ("example" , headerNode , location ,result );
@@ -1758,17 +1766,19 @@ public Object getAnyExample(String nodeKey,ObjectNode node, String location, Par
1758
1766
return null ;
1759
1767
}
1760
1768
1761
- public Map <String , SecurityScheme > getSecuritySchemes (ObjectNode obj , String location , ParseResult result ) {
1769
+ public Map <String , SecurityScheme > getSecuritySchemes (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1762
1770
if (obj == null ) {
1763
1771
return null ;
1764
1772
}
1765
1773
Map <String , SecurityScheme > securitySchemes = new LinkedHashMap <>();
1766
1774
1767
1775
Set <String > securitySchemeKeys = getKeys (obj );
1768
1776
for (String securitySchemeName : securitySchemeKeys ) {
1769
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1770
- securitySchemeName )) {
1771
- result .warning (location , "SecurityScheme name " + securitySchemeName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1777
+ if (underComponents ) {
1778
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
1779
+ securitySchemeName )) {
1780
+ result .warning (location , "SecurityScheme name " + securitySchemeName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
1781
+ }
1772
1782
}
1773
1783
JsonNode securitySchemeValue = obj .get (securitySchemeName );
1774
1784
if (!securitySchemeValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
@@ -1990,17 +2000,19 @@ public OAuthFlow getOAuthFlow(String oAuthFlowType, ObjectNode node, String loca
1990
2000
return oAuthFlow ;
1991
2001
}
1992
2002
1993
- public Map <String , Schema > getSchemas (ObjectNode obj , String location , ParseResult result ) {
2003
+ public Map <String , Schema > getSchemas (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
1994
2004
if (obj == null ) {
1995
2005
return null ;
1996
2006
}
1997
2007
Map <String , Schema > schemas = new LinkedHashMap <>();
1998
2008
1999
2009
Set <String > schemaKeys = getKeys (obj );
2000
2010
for (String schemaName : schemaKeys ) {
2001
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2002
- schemaName )) {
2003
- result .warning (location , "Schema name " + schemaName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2011
+ if (underComponents ) {
2012
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2013
+ schemaName )) {
2014
+ result .warning (location , "Schema name " + schemaName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2015
+ }
2004
2016
}
2005
2017
JsonNode schemaValue = obj .get (schemaName );
2006
2018
if (!schemaValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
@@ -2529,17 +2541,19 @@ private byte[] toBytes( String byteString) {
2529
2541
2530
2542
2531
2543
2532
- public Map <String , Example > getExamples (ObjectNode obj , String location , ParseResult result ) {
2544
+ public Map <String , Example > getExamples (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
2533
2545
if (obj == null ) {
2534
2546
return null ;
2535
2547
}
2536
2548
Map <String , Example > examples = new LinkedHashMap <>();
2537
2549
2538
2550
Set <String > exampleKeys = getKeys (obj );
2539
2551
for (String exampleName : exampleKeys ) {
2540
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2541
- exampleName )) {
2542
- result .warning (location , "Example name " + exampleName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2552
+ if (underComponents ) {
2553
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2554
+ exampleName )) {
2555
+ result .warning (location , "Example name " + exampleName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2556
+ }
2543
2557
}
2544
2558
2545
2559
JsonNode exampleValue = obj .get (exampleName );
@@ -2662,7 +2676,7 @@ public void setStyle(String value, Parameter parameter, String location, ObjectN
2662
2676
}
2663
2677
}
2664
2678
2665
- public ApiResponses getResponses (ObjectNode node , String location , ParseResult result ) {
2679
+ public ApiResponses getResponses (ObjectNode node , String location , ParseResult result , boolean underComponents ) {
2666
2680
if (node == null ) {
2667
2681
return null ;
2668
2682
}
@@ -2671,9 +2685,11 @@ public ApiResponses getResponses(ObjectNode node, String location, ParseResult r
2671
2685
Set <String > keys = getKeys (node );
2672
2686
2673
2687
for (String key : keys ) {
2674
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2675
- key )) {
2676
- result .warning (location , "Response key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2688
+ if (underComponents ) {
2689
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2690
+ key )) {
2691
+ result .warning (location , "Response key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2692
+ }
2677
2693
}
2678
2694
2679
2695
if (key .startsWith ("x-" )) {
@@ -2725,15 +2741,15 @@ public ApiResponse getResponse(ObjectNode node, String location, ParseResult res
2725
2741
2726
2742
ObjectNode headerObject = getObject ("headers" , node , false , location , result );
2727
2743
if (headerObject != null ) {
2728
- Map <String , Header > headers = getHeaders (headerObject , location , result );
2744
+ Map <String , Header > headers = getHeaders (headerObject , location , result , false );
2729
2745
if (headers != null && headers .size () > 0 ) {
2730
2746
apiResponse .setHeaders (headers );
2731
2747
}
2732
2748
}
2733
2749
2734
2750
ObjectNode linksObj = getObject ("links" , node , false , location , result );
2735
2751
if (linksObj != null ) {
2736
- Map <String ,Link > links = getLinks (linksObj , location , result );
2752
+ Map <String ,Link > links = getLinks (linksObj , location , result , false );
2737
2753
if (links != null && links .size () > 0 ) {
2738
2754
apiResponse .setLinks (links );
2739
2755
}
@@ -2819,13 +2835,13 @@ public Operation getOperation(ObjectNode obj, String location, ParseResult resul
2819
2835
}
2820
2836
2821
2837
ObjectNode responsesNode = getObject ("responses" , obj , true , location , result );
2822
- ApiResponses responses = getResponses (responsesNode , String .format ("%s.%s" , location , "responses" ), result );
2838
+ ApiResponses responses = getResponses (responsesNode , String .format ("%s.%s" , location , "responses" ), result , false );
2823
2839
if (responses != null ) {
2824
2840
operation .setResponses (responses );
2825
2841
}
2826
2842
2827
2843
ObjectNode callbacksNode = getObject ("callbacks" , obj , false , location , result );
2828
- Map <String ,Callback > callbacks = getCallbacks (callbacksNode , String .format ("%s.%s" , location , "callbacks" ), result );
2844
+ Map <String ,Callback > callbacks = getCallbacks (callbacksNode , String .format ("%s.%s" , location , "callbacks" ), result , false );
2829
2845
if (callbacks != null ){
2830
2846
operation .setCallbacks (callbacks );
2831
2847
}
@@ -2901,17 +2917,19 @@ public List<SecurityRequirement> getSecurityRequirementsList(ArrayNode nodes, St
2901
2917
2902
2918
}
2903
2919
2904
- public Map <String , RequestBody > getRequestBodies (ObjectNode obj , String location , ParseResult result ) {
2920
+ public Map <String , RequestBody > getRequestBodies (ObjectNode obj , String location , ParseResult result , boolean underComponents ) {
2905
2921
if (obj == null ) {
2906
2922
return null ;
2907
2923
}
2908
2924
Map <String , RequestBody > bodies = new LinkedHashMap <>();
2909
2925
2910
2926
Set <String > bodyKeys = getKeys (obj );
2911
2927
for (String bodyName : bodyKeys ) {
2912
- if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2913
- bodyName )) {
2914
- result .warning (location , "RequestBody name " + bodyName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2928
+ if (underComponents ) {
2929
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
2930
+ bodyName )) {
2931
+ result .warning (location , "RequestBody name " + bodyName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" );
2932
+ }
2915
2933
}
2916
2934
JsonNode bodyValue = obj .get (bodyName );
2917
2935
if (!bodyValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
0 commit comments