path-keys-no-trailing-slash
JSON Path: $.paths
When defining Paths, it’s important to not include a trailing slash at the end of the path definition.
It’s good hygiene to keep trailing slashes off paths, mainly because it can confuse tooling that use the specification for generating code, mocking or other applications. Some tools will get confused, some tools won’t care.
If we have two paths:
- somedomain.com/some/path/
- somedomain.com/some/path
Some tools will treat this as two separate paths, some tools will see them as the same. There isn’t really a good way to know how a tool will react (unless we experiment).
This rule checks that no paths
definition ends with a slash ‘/’.
Why did this violation appear?
One or more paths
definitions contains a trailing slash.
Bad example
paths:
/pizza/{cake}/{icecream}/:
get:
parameters:
...
Good example
paths:
/pizza/{cake}/{icecream}:
get:
parameters:
...
How do I fix this violation?
Ensure there are no paths
definitions that end with a slash ‘/’.
Spectral Equivalent
The rule is equivalent to path-keys-no-trailing-slash