diff --git a/rules/endpoint/path-must-specify-tags.spec.ts b/rules/endpoint/path-must-specify-tags.spec.ts index 38d22aa..40cf32b 100644 --- a/rules/endpoint/path-must-specify-tags.spec.ts +++ b/rules/endpoint/path-must-specify-tags.spec.ts @@ -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', diff --git a/rules/endpoint/path-must-specify-tags.yml b/rules/endpoint/path-must-specify-tags.yml index f035a2e..435e25e 100644 --- a/rules/endpoint/path-must-specify-tags.yml +++ b/rules/endpoint/path-must-specify-tags.yml @@ -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 diff --git a/spectral.yml b/spectral.yml index 04e77d2..a004f1c 100644 --- a/spectral.yml +++ b/spectral.yml @@ -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