|
53 | 53 | import java.net.URISyntaxException;
|
54 | 54 | import java.net.URL;
|
55 | 55 | import java.util.*;
|
| 56 | +import java.util.regex.Pattern; |
56 | 57 | import java.util.stream.Collectors;
|
57 | 58 | import java.util.stream.Stream;
|
58 | 59 |
|
@@ -1019,6 +1020,11 @@ public Map<String, Link> getLinks(ObjectNode obj, String location, ParseResult r
|
1019 | 1020 |
|
1020 | 1021 | Set<String> linkKeys = getKeys(obj);
|
1021 | 1022 | for(String linkName : linkKeys) {
|
| 1023 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 1024 | + linkName)) { |
| 1025 | + result.warning(location, "Link name "+ linkName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 1026 | + } |
| 1027 | + |
1022 | 1028 | JsonNode linkValue = obj.get(linkName);
|
1023 | 1029 | if (!linkValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
1024 | 1030 | result.invalidType(location, linkName, "object", linkValue);
|
@@ -1128,6 +1134,10 @@ public Map <String,Callback> getCallbacks(ObjectNode node, String location, Pars
|
1128 | 1134 | Map<String, Callback> callbacks = new LinkedHashMap<>();
|
1129 | 1135 | Set<String> keys = getKeys(node);
|
1130 | 1136 | for(String key : keys) {
|
| 1137 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 1138 | + key)) { |
| 1139 | + result.warning(location, "Callback key "+ key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 1140 | + } |
1131 | 1141 | Callback callback = getCallback((ObjectNode) node.get(key), location, result);
|
1132 | 1142 | if (callback != null) {
|
1133 | 1143 | callbacks.put(key, callback);
|
@@ -1307,6 +1317,11 @@ public Map<String, Parameter> getParameters(ObjectNode obj, String location, Par
|
1307 | 1317 |
|
1308 | 1318 | Set<String> parameterKeys = getKeys(obj);
|
1309 | 1319 | for(String parameterName : parameterKeys) {
|
| 1320 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 1321 | + parameterName)) { |
| 1322 | + result.warning(location, "Parameter name "+ parameterName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 1323 | + } |
| 1324 | + |
1310 | 1325 | JsonNode parameterValue = obj.get(parameterName);
|
1311 | 1326 | if (parameterValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
1312 | 1327 | ObjectNode parameterObj = (ObjectNode) parameterValue;
|
@@ -1485,6 +1500,10 @@ public Map<String, Header> getHeaders(ObjectNode obj, String location, ParseResu
|
1485 | 1500 |
|
1486 | 1501 | Set<String> headerKeys = getKeys(obj);
|
1487 | 1502 | for(String headerName : headerKeys) {
|
| 1503 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 1504 | + headerName)) { |
| 1505 | + result.warning(location, "Header name "+ headerName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 1506 | + } |
1488 | 1507 | JsonNode headerValue = obj.get(headerName);
|
1489 | 1508 | if (!headerValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
1490 | 1509 | result.invalidType(location, headerName, "object", headerValue);
|
@@ -1627,6 +1646,10 @@ public Map<String, SecurityScheme> getSecuritySchemes(ObjectNode obj, String loc
|
1627 | 1646 |
|
1628 | 1647 | Set<String> securitySchemeKeys = getKeys(obj);
|
1629 | 1648 | for(String securitySchemeName : securitySchemeKeys) {
|
| 1649 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 1650 | + securitySchemeName)) { |
| 1651 | + result.warning(location, "SecurityScheme name "+ securitySchemeName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 1652 | + } |
1630 | 1653 | JsonNode securitySchemeValue = obj.get(securitySchemeName);
|
1631 | 1654 | if (!securitySchemeValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
1632 | 1655 | result.invalidType(location, securitySchemeName, "object", securitySchemeValue);
|
@@ -1855,6 +1878,10 @@ public Map<String, Schema> getSchemas(ObjectNode obj, String location, ParseResu
|
1855 | 1878 |
|
1856 | 1879 | Set<String> schemaKeys = getKeys(obj);
|
1857 | 1880 | for (String schemaName : schemaKeys) {
|
| 1881 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 1882 | + schemaName)) { |
| 1883 | + result.warning(location, "Schema name "+ schemaName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 1884 | + } |
1858 | 1885 | JsonNode schemaValue = obj.get(schemaName);
|
1859 | 1886 | if (!schemaValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
1860 | 1887 | result.invalidType(location, schemaName, "object", schemaValue);
|
@@ -2226,6 +2253,11 @@ public Map<String, Example> getExamples(ObjectNode obj, String location, ParseRe
|
2226 | 2253 |
|
2227 | 2254 | Set<String> exampleKeys = getKeys(obj);
|
2228 | 2255 | for(String exampleName : exampleKeys) {
|
| 2256 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 2257 | + exampleName)) { |
| 2258 | + result.warning(location, "Example name "+ exampleName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 2259 | + } |
| 2260 | + |
2229 | 2261 | JsonNode exampleValue = obj.get(exampleName);
|
2230 | 2262 | if (!exampleValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
2231 | 2263 | result.invalidType(location, exampleName, "object", exampleValue);
|
@@ -2355,6 +2387,11 @@ public ApiResponses getResponses(ObjectNode node, String location, ParseResult r
|
2355 | 2387 | Set<String> keys = getKeys(node);
|
2356 | 2388 |
|
2357 | 2389 | for (String key : keys) {
|
| 2390 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 2391 | + key)) { |
| 2392 | + result.warning(location, "Response key "+ key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 2393 | + } |
| 2394 | + |
2358 | 2395 | if (key.startsWith("x-")) {
|
2359 | 2396 | Map <String,Object> extensions = getExtensions(node);
|
2360 | 2397 | if(extensions != null && extensions.size() > 0) {
|
@@ -2588,6 +2625,10 @@ public Map<String, RequestBody> getRequestBodies(ObjectNode obj, String location
|
2588 | 2625 |
|
2589 | 2626 | Set<String> bodyKeys = getKeys(obj);
|
2590 | 2627 | for(String bodyName : bodyKeys) {
|
| 2628 | + if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", |
| 2629 | + bodyName)) { |
| 2630 | + result.warning(location, "RequestBody name "+ bodyName + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); |
| 2631 | + } |
2591 | 2632 | JsonNode bodyValue = obj.get(bodyName);
|
2592 | 2633 | if (!bodyValue.getNodeType().equals(JsonNodeType.OBJECT)) {
|
2593 | 2634 | result.invalidType(location, bodyName, "object", bodyValue);
|
|
0 commit comments