Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(path-must-specify-tags): only include http verbs when checking for tags #35

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading