Skip to content

Commit e59bd40

Browse files
authored
Merge pull request #31 from azetilov/fix/rest-paths-kebab-case
fix(spectral): use kebab-case for paths
2 parents 7ef47e6 + bc51ece commit e59bd40

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

.spectral.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,27 @@ rules:
99
operation-tags: false
1010
operation-2xx-response: error
1111

12-
adidas-paths-camelCase:
13-
description: All YAML/JSON paths MUST follow camelCase
12+
adidas-paths-kebab-case:
13+
description: All YAML/JSON paths MUST follow kebab-case
1414
severity: warn
1515
recommended: true
16-
message: "{{property}} is not camelCase: {{error}}"
16+
message: "{{property}} is not kebab-case: {{error}}"
1717
given: $.paths[*]~
1818
then:
1919
function: pattern
2020
functionOptions:
21-
# match: "/^(\/{1}(([{]?[a-z])[A-Za-z0-9]*[}]?)*)+$/" # - more generic one, allows /asasd{asdas}sadas pattern but also not closed braces
22-
match: "^\/([a-z][a-zA-Z0-9]+)?(\/[a-z][a-zA-Z0-9]+|\/{[a-z][a-zA-Z0-9]+})*$" # doesn't allow /asasd{asdas}sadas pattern or not closed braces
21+
match: "^\/([a-z0-9]+(-[a-z0-9]+)*)?(\/[a-z0-9]+(-[a-z0-9]+)*|\/{.+})*$" # doesn't allow /asasd{asdas}sadas pattern or not closed braces
22+
23+
adidas-path-parameters-camelCase-alphanumeric:
24+
description: Path parameters MUST follow camelCase
25+
severity: warn
26+
recommended: true
27+
message: "{{property}} path parameter is not camelCase: {{error}}"
28+
given: $..parameters[?(@.in == 'path')].name
29+
then:
30+
function: pattern
31+
functionOptions:
32+
match: "^[a-z][a-zA-Z0-9]+$"
2333

2434
adidas-definitions-camelCase-alphanumeric:
2535
description: All YAML/JSON definitions MUST follow fields-camelCase and be ASCII alphanumeric characters or `_` or `$`.
@@ -52,17 +62,6 @@ rules:
5262
functionOptions:
5363
notMatch: "/^body$/"
5464

55-
adidas-uri-template-cannot-dash:
56-
description: "The 'URI' template (RFC 6570 - https://tools.ietf.org/html/rfc6570) cannot contain a '-' character"
57-
severity: error
58-
recommended: true
59-
message: "{{property}}: {{description}}"
60-
given: "$.paths[*]~"
61-
then:
62-
function: pattern
63-
functionOptions:
64-
notMatch: "/-/"
65-
6665
adidas-headers-no-x-headers:
6766
description: "All 'HTTP' headers SHOULD NOT include 'X-' headers (https://tools.ietf.org/html/rfc6648)."
6867
severity: warn

0 commit comments

Comments
 (0)