From 580cc0cee97b6419595a7f82265435d11707e08c Mon Sep 17 00:00:00 2001 From: Anatolii Zetilov Date: Tue, 17 Mar 2020 16:10:47 +0200 Subject: [PATCH 1/2] fix(spectral): indentation --- .spectral.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.spectral.yml b/.spectral.yml index 85a8bf5..00cdafe 100644 --- a/.spectral.yml +++ b/.spectral.yml @@ -9,17 +9,16 @@ rules: operation-tags: false operation-2xx-response: error - adidas-paths-camelCase: - description: All YAML/JSON paths MUST follow camelCase + adidas-paths-kebab-case: + description: All YAML/JSON paths MUST follow kebab-case with template variables in camelCase severity: warn recommended: true - message: "{{property}} is not camelCase: {{error}}" + message: "{{property}} is not kebab-case: {{error}}" given: $.paths[*]~ then: function: pattern functionOptions: - # match: "/^(\/{1}(([{]?[a-z])[A-Za-z0-9]*[}]?)*)+$/" # - more generic one, allows /asasd{asdas}sadas pattern but also not closed braces - 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 + match: "^\/([a-z0-9]+(-[a-z0-9]+)*)?(\/[a-z0-9]+(-[a-z0-9]+)*|\/{[a-z][a-zA-Z0-9]+})*$" # doesn't allow /asasd{asdas}sadas pattern or not closed braces adidas-definitions-camelCase-alphanumeric: description: All YAML/JSON definitions MUST follow fields-camelCase and be ASCII alphanumeric characters or `_` or `$`. @@ -52,17 +51,6 @@ rules: functionOptions: notMatch: "/^body$/" - adidas-uri-template-cannot-dash: - description: "The 'URI' template (RFC 6570 - https://tools.ietf.org/html/rfc6570) cannot contain a '-' character" - severity: error - recommended: true - message: "{{property}}: {{description}}" - given: "$.paths[*]~" - then: - function: pattern - functionOptions: - notMatch: "/-/" - adidas-headers-no-x-headers: description: "All 'HTTP' headers SHOULD NOT include 'X-' headers (https://tools.ietf.org/html/rfc6648)." severity: warn From bc51ece3bf36516378eba5f782a06180b4b12d33 Mon Sep 17 00:00:00 2001 From: Anatolii Zetilov Date: Wed, 25 Mar 2020 16:39:47 +0200 Subject: [PATCH 2/2] fix(spectral): separate rule for path parameters --- .spectral.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.spectral.yml b/.spectral.yml index 00cdafe..5269301 100644 --- a/.spectral.yml +++ b/.spectral.yml @@ -10,7 +10,7 @@ rules: operation-2xx-response: error adidas-paths-kebab-case: - description: All YAML/JSON paths MUST follow kebab-case with template variables in camelCase + description: All YAML/JSON paths MUST follow kebab-case severity: warn recommended: true message: "{{property}} is not kebab-case: {{error}}" @@ -18,7 +18,18 @@ rules: then: function: pattern functionOptions: - match: "^\/([a-z0-9]+(-[a-z0-9]+)*)?(\/[a-z0-9]+(-[a-z0-9]+)*|\/{[a-z][a-zA-Z0-9]+})*$" # doesn't allow /asasd{asdas}sadas pattern or not closed braces + match: "^\/([a-z0-9]+(-[a-z0-9]+)*)?(\/[a-z0-9]+(-[a-z0-9]+)*|\/{.+})*$" # doesn't allow /asasd{asdas}sadas pattern or not closed braces + + adidas-path-parameters-camelCase-alphanumeric: + description: Path parameters MUST follow camelCase + severity: warn + recommended: true + message: "{{property}} path parameter is not camelCase: {{error}}" + given: $..parameters[?(@.in == 'path')].name + then: + function: pattern + functionOptions: + match: "^[a-z][a-zA-Z0-9]+$" adidas-definitions-camelCase-alphanumeric: description: All YAML/JSON definitions MUST follow fields-camelCase and be ASCII alphanumeric characters or `_` or `$`.