From 020eb5bb2b666686d3871ea932ce9d432fee3b2e Mon Sep 17 00:00:00 2001 From: Mark DeBeer Date: Tue, 10 Dec 2024 16:27:36 -0500 Subject: [PATCH 1/3] Disable the rules and tests for now --- rulesets/src/collections.ruleset.yml | 69 ++++++++++--------- ...ps-no-collection-paging-capability.test.js | 6 +- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/rulesets/src/collections.ruleset.yml b/rulesets/src/collections.ruleset.yml index e9ad3ef..ee391a8 100644 --- a/rulesets/src/collections.ruleset.yml +++ b/rulesets/src/collections.ruleset.yml @@ -1,31 +1,33 @@ rules: ##### General ##### - sps-no-collection-paging-capability: - description: "Response bodies from collection endpoints SHOULD offer paging capability." - severity: warn - given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].get.responses['200'].content.application/json.schema.properties - then: - - field: "paging" - function: truthy - - field: "paging.type" - function: pattern - functionOptions: - match: "object" + # See https://atlassian.spscommerce.com/browse/DPE-286 + # sps-no-collection-paging-capability: + # description: "Response bodies from collection endpoints SHOULD offer paging capability." + # severity: warn + # given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].get.responses['200'].content.application/json.schema.properties + # then: + # - field: "paging" + # function: truthy + # - field: "paging.type" + # function: pattern + # functionOptions: + # match: "object" ##### Root Element ##### - sps-collection-missing-results-array: - description: "Response bodies must have a root element called results and is an array of objects." - severity: error - given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].get.responses['200'].content.application/json.schema.properties.results - then: - - field: type - function: pattern - functionOptions: - match: "array" - - field: items.type - function: pattern - functionOptions: - match: "object" + # https://atlassian.spscommerce.com/browse/DPE-286 + # sps-collection-missing-results-array: + # description: "Response bodies must have a root element called results and is an array of objects." + # severity: error + # given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].get.responses['200'].content.application/json.schema.properties.results + # then: + # - field: type + # function: pattern + # functionOptions: + # match: "array" + # - field: items.type + # function: pattern + # functionOptions: + # match: "object" ##### Pagination ##### sps-missing-pagination-query-parameters: @@ -64,15 +66,16 @@ rules: in: const: query - sps-post-request-body-missing-paging-object: - description: "POST collection endpoints MUST have a request body schema that includes paging parameters." - severity: error - given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].post.requestBody.content.application/json.schema.properties.paging - then: - field: "type" - function: pattern - functionOptions: - match: "object" + # sps-post-request-body-missing-paging-object: + # See https://atlassian.spscommerce.com/browse/DPE-286 + # description: "POST collection endpoints MUST have a request body schema that includes paging parameters." + # severity: error + # given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].post.requestBody.content.application/json.schema.properties.paging + # then: + # field: "type" + # function: pattern + # functionOptions: + # match: "object" ##### FILTERING ##### sps-disallow-resource-identifier-filtering: diff --git a/rulesets/test/collections/sps-no-collection-paging-capability.test.js b/rulesets/test/collections/sps-no-collection-paging-capability.test.js index a8d10ef..ca348db 100644 --- a/rulesets/test/collections/sps-no-collection-paging-capability.test.js +++ b/rulesets/test/collections/sps-no-collection-paging-capability.test.js @@ -60,7 +60,8 @@ describe("sps-no-collection-paging-capability", () => { await spectral.validateSuccess(spec, ruleName); }); - test("invalid - response body - missing paging object", async () => { + // Re-enable with https://atlassian.spscommerce.com/browse/DPE-286 + test.skip("invalid - response body - missing paging object", async () => { const spec = ` openapi: 3.0.0 info: @@ -95,7 +96,8 @@ describe("sps-no-collection-paging-capability", () => { await spectral.validateFailure(spec, ruleName, "Warning", 1); }); - test("invalid - response body - paging element must be an object", async () => { + // Re-enable with https://atlassian.spscommerce.com + test.skip("invalid - response body - paging element must be an object", async () => { const spec = ` openapi: 3.0.0 info: From f6f84d555b2a26e2910798f0a52a388b5c2c3a73 Mon Sep 17 00:00:00 2001 From: Mark DeBeer Date: Tue, 10 Dec 2024 16:34:26 -0500 Subject: [PATCH 2/3] Skip other failing tests --- .../collections/sps-collection-missing-results-array.test.js | 4 ++-- .../sps-post-request-body-missing-paging-object.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rulesets/test/collections/sps-collection-missing-results-array.test.js b/rulesets/test/collections/sps-collection-missing-results-array.test.js index 242b86a..269f216 100644 --- a/rulesets/test/collections/sps-collection-missing-results-array.test.js +++ b/rulesets/test/collections/sps-collection-missing-results-array.test.js @@ -37,7 +37,7 @@ describe("sps-collection-missing-results-array", () => { await spectral.validateSuccess(spec, ruleName); }); - test("invalid - collection response - results is not an array", async () => { + test.skip("invalid - collection response - results is not an array", async () => { const spec = ` openapi: 3.0.0 info: @@ -63,7 +63,7 @@ describe("sps-collection-missing-results-array", () => { await spectral.validateFailure(spec, ruleName, "Error", 1); }); - test("invalid - collection response - results is not an array of objects", async () => { + test.skip("invalid - collection response - results is not an array of objects", async () => { const spec = ` openapi: 3.0.0 info: diff --git a/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js b/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js index 581d358..6733e89 100644 --- a/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js +++ b/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js @@ -63,7 +63,7 @@ describe("sps-post-request-body-missing-paging-object", () => { await spectral.validateSuccess(spec, ruleName); }); - test("invalid - POST endpoint has incorrect paging type - string", async () => { + test.skip("invalid - POST endpoint has incorrect paging type - string", async () => { const spec = ` openapi: 3.1.0 paths: From 6646b1ee678cc3222bcc3ffe4404440dd7a649dc Mon Sep 17 00:00:00 2001 From: Mark DeBeer Date: Tue, 10 Dec 2024 16:45:53 -0500 Subject: [PATCH 3/3] Re-enable some rules and tests --- rulesets/src/collections.ruleset.yml | 46 +++++++++---------- ...s-collection-missing-results-array.test.js | 4 +- ...request-body-missing-paging-object.test.js | 2 +- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/rulesets/src/collections.ruleset.yml b/rulesets/src/collections.ruleset.yml index ee391a8..4445233 100644 --- a/rulesets/src/collections.ruleset.yml +++ b/rulesets/src/collections.ruleset.yml @@ -14,20 +14,19 @@ rules: # match: "object" ##### Root Element ##### - # https://atlassian.spscommerce.com/browse/DPE-286 - # sps-collection-missing-results-array: - # description: "Response bodies must have a root element called results and is an array of objects." - # severity: error - # given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].get.responses['200'].content.application/json.schema.properties.results - # then: - # - field: type - # function: pattern - # functionOptions: - # match: "array" - # - field: items.type - # function: pattern - # functionOptions: - # match: "object" + sps-collection-missing-results-array: + description: "Response bodies must have a root element called results and is an array of objects." + severity: error + given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].get.responses['200'].content.application/json.schema.properties.results + then: + - field: type + function: pattern + functionOptions: + match: "array" + - field: items.type + function: pattern + functionOptions: + match: "object" ##### Pagination ##### sps-missing-pagination-query-parameters: @@ -66,16 +65,15 @@ rules: in: const: query - # sps-post-request-body-missing-paging-object: - # See https://atlassian.spscommerce.com/browse/DPE-286 - # description: "POST collection endpoints MUST have a request body schema that includes paging parameters." - # severity: error - # given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].post.requestBody.content.application/json.schema.properties.paging - # then: - # field: "type" - # function: pattern - # functionOptions: - # match: "object" + sps-post-request-body-missing-paging-object: + description: "POST collection endpoints MUST have a request body schema that includes paging parameters." + severity: error + given: $.paths[?(!@property.match(/.*\/\{[^}]+\}$/))].post.requestBody.content.application/json.schema.properties.paging + then: + field: "type" + function: pattern + functionOptions: + match: "object" ##### FILTERING ##### sps-disallow-resource-identifier-filtering: diff --git a/rulesets/test/collections/sps-collection-missing-results-array.test.js b/rulesets/test/collections/sps-collection-missing-results-array.test.js index 269f216..242b86a 100644 --- a/rulesets/test/collections/sps-collection-missing-results-array.test.js +++ b/rulesets/test/collections/sps-collection-missing-results-array.test.js @@ -37,7 +37,7 @@ describe("sps-collection-missing-results-array", () => { await spectral.validateSuccess(spec, ruleName); }); - test.skip("invalid - collection response - results is not an array", async () => { + test("invalid - collection response - results is not an array", async () => { const spec = ` openapi: 3.0.0 info: @@ -63,7 +63,7 @@ describe("sps-collection-missing-results-array", () => { await spectral.validateFailure(spec, ruleName, "Error", 1); }); - test.skip("invalid - collection response - results is not an array of objects", async () => { + test("invalid - collection response - results is not an array of objects", async () => { const spec = ` openapi: 3.0.0 info: diff --git a/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js b/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js index 6733e89..581d358 100644 --- a/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js +++ b/rulesets/test/collections/sps-post-request-body-missing-paging-object.test.js @@ -63,7 +63,7 @@ describe("sps-post-request-body-missing-paging-object", () => { await spectral.validateSuccess(spec, ruleName); }); - test.skip("invalid - POST endpoint has incorrect paging type - string", async () => { + test("invalid - POST endpoint has incorrect paging type - string", async () => { const spec = ` openapi: 3.1.0 paths: