From 4eddeedb62eab33af161cf80de1b28121b70f2f7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 21 Jun 2023 20:48:36 +0000 Subject: [PATCH] chore(release): 1.5.0 [skip ci] # [1.5.0](https://github.com/SPSCommerce/sps-api-standards/compare/v1.4.1...v1.5.0) (2023-06-21) ### Features * Localhost Exceptions & Inaccurate Long Resource Paths ([#57](https://github.com/SPSCommerce/sps-api-standards/issues/57)) ([db195e7](https://github.com/SPSCommerce/sps-api-standards/commit/db195e78ae7a63f680c80b2a0edba8468fbc355e)), closes [#31](https://github.com/SPSCommerce/sps-api-standards/issues/31) --- sps-api-standards.spectral.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sps-api-standards.spectral.yml b/sps-api-standards.spectral.yml index 9480210..431569f 100644 --- a/sps-api-standards.spectral.yml +++ b/sps-api-standards.spectral.yml @@ -209,14 +209,14 @@ rules: functionOptions: max: 100 sps-hosts-https-only: - message: "Servers MUST be https and no other protocol is allowed." + message: "Servers MUST be https and no other protocol is allowed unless using localhost." formats: [oas3] severity: error given: $.servers..url then: function: pattern functionOptions: - match: "/^https:/" + match: ^(https:|http://localhost) sps-hosts-lowercase: message: "Server URL SHOULD BE lowercase." formats: [oas3] @@ -234,7 +234,7 @@ rules: then: function: pattern functionOptions: - match: api.spscommerce.com|api.sps-internal.com + match: api.spscommerce.com|api.sps-internal.com|localhost sps-path-no-environment: message: "API paths MUST NOT indicate environment names." severity: error @@ -244,14 +244,14 @@ rules: functionOptions: notMatch: /prod/|/preprod/|/dev/|/test/|/integration/|/stage/ sps-hosts-no-port: - message: "Port MUST NOT be specified or required to use the API." + message: "Port MUST NOT be specified or required to use the API, except for 'localhost' testing in a spec." formats: [oas3] severity: error given: $.servers..url then: function: pattern functionOptions: - notMatch: (https?://.*):(\d*)\/?(.*) + notMatch: (?!https?://localhost)(https?://.*):(\d*)\/?(.*) sps-paths-expose-technology: message: "A resource MUST NOT leak or expose format or technology-specific information at any point in the path." severity: error @@ -309,14 +309,22 @@ rules: function: pattern functionOptions: notMatch: // + sps-paths-limit-path-parameters: + message: The URL path should not contain more than 3 dynamic path parameters. + severity: warn + given: $.paths.*~ + then: + function: pattern + functionOptions: + notMatch: ^(.*{{1}.*){4,} sps-paths-limit-sub-resources: - message: The hierarchy of nested resources SHOULD NOT exceed more than 3 resources + message: The hierarchy of nested resources SHOULD NOT contain more than 8 resource names in the path. severity: warn given: $.paths.*~ then: function: pattern functionOptions: - match: ^\/[^\/]*((\/{[^}]*})*\/[^\/]*(\/{[^}]*})*){0,3}\/?$ + notMatch: ^(.*\/{1}.*){9,} sps-paths-with-http-methods: message: "A resource SHOULD NOT contain HTTP methods." severity: error