When using an API spec which defines an empty servers array and the WithAddServerUrls option ...
servers: []
... linting the API spec may fail with this error:
Servers must be a non-empty array.
6 | description: Aggregated API server which contains all APIs related to FREEZE
7 |
8 | servers: []
| ^^^^^^^
9 |
10 | security: []
Error was generated by the no-empty-servers rule.
If you omit the servers array, the error is kind of similar:
Servers must be present.
1 | openapi: 3.0.0
2 |
3 | info:
Error was generated by the no-empty-servers rule.
Reproduction
Use an API spec like specified and run a linter on it, i used: npx @redocly/cli lint openapi.yaml
Expected
To work arround this, I would add a dummy entry like this:
servers:
- url: http://localhost/
and then I'd expect that the WithAddServerUrls would remove this dummy entry.
If this behaviour should be optional, we could change WithAddServerUrls to take a parameter such as this:
When using an API spec which defines an empty servers array and the
WithAddServerUrls
option ...... linting the API spec may fail with this error:
If you omit the
servers
array, the error is kind of similar:Reproduction
Use an API spec like specified and run a linter on it, i used:
npx @redocly/cli lint openapi.yaml
Expected
To work arround this, I would add a dummy entry like this:
and then I'd expect that the
WithAddServerUrls
would remove this dummy entry.If this behaviour should be optional, we could change
WithAddServerUrls
to take a parameter such as this:If this parameter is true, it would remove any existing elements from the
servers
array.