spectral:asyncapi error on by default

asyncapi-server-variables

Server variables must be defined and there must be no redundant variables.

Applies to
servers
Selects
$.servers.*
$.components.servers.*
Function
serverVariables
Specs
AsyncAPI 2.x
Message
{{error}}

Use it

This rule ships with OpenLint in spectral:asyncapi. Extending the ruleset turns it on:

extends: spectral:asyncapi
rules:
  asyncapi-server-variables: error   # or off, or another severity

Definition

As defined in @openlint/openlint-rulesets. Functions show by name.

asyncapi-server-variables:
  description: Server variables must be defined and there must be no redundant variables.
  message: '{{error}}'
  severity: error
  recommended: true
  formats:
    - AsyncAPI 2.x
  given:
    - $.servers.*
    - $.components.servers.*
  then:
    function: serverVariables

About this rule

All server URL variables should be defined in the variables object of the server. They should also not contain redundant variables that do not exist in the server address.

Sources