Ensures that paths in your API do not end with a trailing slash (/).
| OAS | Compatibility |
|---|---|
| 2.0 | ✅ |
| 3.0 | ✅ |
| 3.1 | ✅ |
Some web tooling (like mock servers, real servers, code generators, application frameworks, etc.) treats example.com/foo and example.com/foo/ as the same thing, but other tooling does not.
Technically speaking, they are different because the trailing slash indicates there is another resource identified by an empty string.
Enable this rule to avoid confusion in your documentation. When it comes to developer experience, consistency rules.
| Option | Type | Description |
|---|---|---|
| severity | string | Possible values: off, warn, error. Default error (in recommended configuration). |
An example configuration:
rules:
no-path-trailing-slash: errorGiven this configuration:
rules:
no-path-trailing-slash: errorExample of incorrect path:
paths:
/customers/:
$ref: ./paths/customers.yamlExample of correct path:
paths:
/customers:
$ref: ./paths/customers.yaml