Skip to content

Commit

Permalink
fix(path-must-specify-tags): only include htp verbs when checking for…
Browse files Browse the repository at this point in the history
… tags inside them
  • Loading branch information
markbrockhoff committed Jul 20, 2023
1 parent 11820fd commit 923cb36
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions rules/endpoint/path-must-specify-tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ describe("path-must-specify-tags", () => {
expect(result).toHaveLength(0);
});

it('ignores non http verb fields', async () => {
const result = await spectral.run(JSON.stringify({
openapi: "3.0",
paths: {
"/test/{param}": {
summary: "",
description: "",
servers: [],
parameters: [{
name: 'param',
in: "path",
schema: {type: "string"}
}]
}
}
}))
expect(result).toHaveLength(0);
})

const getTestSpec = (tags?: string[], path = "/api/some/path") =>
JSON.stringify({
openapi: '3.0',
Expand Down
2 changes: 1 addition & 1 deletion rules/endpoint/path-must-specify-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rules:
severity: error
formats:
- oas3
given: $.paths[?(!@property.match(/well-known/ig))].*
given: $.paths[?(!@property.match(/well-known/ig))].[get,post,put,delete,patch,options,head,trace]
then:
- field: tags
function: truthy
Expand Down
2 changes: 1 addition & 1 deletion spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ rules:
description: Every route must specify at least one tag it belongs to
message: "{{description}}; property tags is missing at: {{path}}"
severity: error
given: $.paths[?(!@property.match(/well-known/ig))].*
given: $.paths[?(!@property.match(/well-known/ig))].[get,post,put,delete,patch,options,head,trace]
then:
- field: tags
function: truthy
Expand Down

0 comments on commit 923cb36

Please sign in to comment.