Skip to content

Commit

Permalink
fix: allow path-keys-no-trailing-slash empty slash (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc MacLeod committed Feb 4, 2019
1 parent 5900c3a commit 33a4a06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/rulesets/oas/__tests__/path-keys-no-trailing-slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion src/rulesets/oas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export const commonOasRules = (): RuleCollection => ({
field: '@key',
function: RuleFunction.PATTERN,
functionOptions: {
notMatch: '/$',
notMatch: '.+\\/$',
},
},
tags: ['given'],
Expand Down

0 comments on commit 33a4a06

Please sign in to comment.