diff --git a/rulesets/src/collections.ruleset.yml b/rulesets/src/collections.ruleset.yml index ecb35f5..84af18a 100644 --- a/rulesets/src/collections.ruleset.yml +++ b/rulesets/src/collections.ruleset.yml @@ -114,12 +114,10 @@ rules: # in: # const: query -# This rule might need to be reworked. -# Hybird filter is possible but it should error if root level filter exist with hybird filter. sps-hybird-filtering-exists-with-root-filter: description: "Hybrid filtering MAY be offered on multiple attributes, but MUST never exist if a root \"filter\" query parameter is present." severity: error - given: $.paths..get + given: $.paths..get.parameters^ then: function: schema functionOptions: @@ -135,11 +133,6 @@ rules: type: string in: type: string - required: - type: boolean - required: - - name - - in allOf: - if: properties: diff --git a/rulesets/test/collections/sps-hybird-filtering-exists-with-root-filter.test.js b/rulesets/test/collections/sps-hybird-filtering-exists-with-root-filter.test.js index 7d488db..3d17691 100644 --- a/rulesets/test/collections/sps-hybird-filtering-exists-with-root-filter.test.js +++ b/rulesets/test/collections/sps-hybird-filtering-exists-with-root-filter.test.js @@ -26,9 +26,9 @@ describe("sps-hybird-filtering-exists-with-root-filter", () => { - name: active in: query required: false - responses: - '200': - description: A list of users + responses: + '200': + description: A list of users `; await spectral.validateSuccess(spec, ruleName); @@ -51,9 +51,26 @@ describe("sps-hybird-filtering-exists-with-root-filter", () => { - name: foo in: query required: false - responses: - '200': - description: A list of users + responses: + '200': + description: A list of users + `; + + await spectral.validateSuccess(spec, ruleName); + }); + + test("valid - endpoint has no query parameter", async () => { + const spec = ` + openapi: 3.0.0 + info: + title: Sample API + version: 1.0.0 + paths: + /ping: + get: + responses: + '200': + description: health check `; await spectral.validateSuccess(spec, ruleName); @@ -76,9 +93,9 @@ describe("sps-hybird-filtering-exists-with-root-filter", () => { - name: userFilter in: query required: false - responses: - '200': - description: A list of users + responses: + '200': + description: A list of users `; await spectral.validateSuccess(spec, ruleName); @@ -104,9 +121,9 @@ describe("sps-hybird-filtering-exists-with-root-filter", () => { - name: userFilter in: query required: false - responses: - '200': - description: A list of users + responses: + '200': + description: A list of users `; await spectral.validateFailure(spec, ruleName, "Error", 1); @@ -129,9 +146,9 @@ describe("sps-hybird-filtering-exists-with-root-filter", () => { - name: userFilter in: query required: false - responses: - '200': - description: A list of users + responses: + '200': + description: A list of users `; await spectral.validateSuccess(spec, ruleName);