spectral:asyncapi error on by default

asyncapi-channel-servers

Channel servers must be defined in the "servers" object.

Applies to
servers
Selects
$
Function
asyncApi2ChannelServers
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-channel-servers: error   # or off, or another severity

Definition

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

asyncapi-channel-servers:
  description: Channel servers must be defined in the "servers" object.
  message: '{{error}}'
  severity: error
  recommended: true
  formats:
    - AsyncAPI 2.x
  given: $
  then:
    function: asyncApi2ChannelServers

About this rule

Channel servers must be defined in the servers object.

Bad Example

asyncapi: "2.0.0"
info:
  title: Awesome API
  description: A very well-defined API
  version: "1.0"
servers:
  production:
    url: "stoplight.io"
    protocol: "https"
channels:
  hello:
    servers:
      - development

Good Example

asyncapi: "2.0.0"
info:
  title: Awesome API
  description: A very well-defined API
  version: "1.0"
servers:
  production:
    url: "stoplight.io"
    protocol: "https"
channels:
  hello:
    servers:
      - production

Sources