oas3-api-servers
OpenAPI "servers" must be present and non-empty array.
- Applies to
servers- Selects
$- Function
schema- Specs
- OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
Use it
This rule ships with OpenLint in spectral:oas. Extending the ruleset turns it on:
extends: spectral:oas
rules:
oas3-api-servers: warn # or off, or another severity
Definition
As defined in @openlint/openlint-rulesets. Functions show by name.
oas3-api-servers:
description: OpenAPI "servers" must be present and non-empty array.
recommended: true
formats:
- OpenAPI 3.x
given: $
then:
field: servers
function: schema
functionOptions:
dialect: draft7
schema:
items:
type: object
minItems: 1
type: array
About this rule
OpenAPI servers must be present and non-empty array.
Share links to any servers that people might care about. If this is going to be given to internal people then usually that is localhost (so they know the right port number), staging, and production.
servers:
- url: https://example.com/api
description: Production server
- url: https://staging.example.com/api
description: Staging server
- url: http://localhost:3001
description: Development server
If this is going out to the world, maybe have production and a general sandbox people can play with.