diff --git a/src/rulesets/oas/__tests__/__snapshots__/path-keys-no-trailing-slash.ts.snap b/src/rulesets/oas/__tests__/__snapshots__/path-keys-no-trailing-slash.ts.snap index ace72c105..cd32691ea 100644 --- a/src/rulesets/oas/__tests__/__snapshots__/path-keys-no-trailing-slash.ts.snap +++ b/src/rulesets/oas/__tests__/__snapshots__/path-keys-no-trailing-slash.ts.snap @@ -3,7 +3,7 @@ exports[`path-keys-no-trailing-slash return errors if path ends with a slash 1`] = ` Array [ Object { - "message": "must not match the pattern '/$'", + "message": "must not match the pattern '.+\\\\/$'", "name": "path-keys-no-trailing-slash", "path": Array [ "paths", diff --git a/src/rulesets/oas/__tests__/path-keys-no-trailing-slash.ts b/src/rulesets/oas/__tests__/path-keys-no-trailing-slash.ts index 908e98e59..f93423b59 100644 --- a/src/rulesets/oas/__tests__/path-keys-no-trailing-slash.ts +++ b/src/rulesets/oas/__tests__/path-keys-no-trailing-slash.ts @@ -26,4 +26,12 @@ describe('path-keys-no-trailing-slash', () => { }); expect(results.results).toMatchSnapshot(); }); + + test('does not return error if path IS a /', () => { + const results = s.run({ + swagger: '2.0', + paths: { '/': {} }, + }); + expect(results.results.length).toEqual(0); + }); }); diff --git a/src/rulesets/oas/index.ts b/src/rulesets/oas/index.ts index 002ed896f..96a681bab 100644 --- a/src/rulesets/oas/index.ts +++ b/src/rulesets/oas/index.ts @@ -329,7 +329,7 @@ export const commonOasRules = (): RuleCollection => ({ field: '@key', function: RuleFunction.PATTERN, functionOptions: { - notMatch: '/$', + notMatch: '.+\\/$', }, }, tags: ['given'],