Skip to content

Commit

Permalink
removed comments and updated unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sps-benjacobs committed Jul 24, 2024
1 parent 009041a commit c6fdef8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
9 changes: 1 addition & 8 deletions rulesets/src/collections.ruleset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -135,11 +133,6 @@ rules:
type: string
in:
type: string
required:
type: boolean
required:
- name
- in
allOf:
- if:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c6fdef8

Please sign in to comment.