servers-defined

Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error

This rule checks whether at least one server is defined in an AsyncAPI document.

Rule details

Servers tell consumers where the application’s channels are available: which broker to connect to, and with which protocol. Without them, the document describes messages but not how to reach them.

The servers-defined rule reports No servers defined when the root servers map is missing or empty. Servers defined only under components/servers do not count.

Turn the rule off for documents that describe messages shared by several applications, and whose servers are defined elsewhere.

Examples

Good.

asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
servers:
  production:
    host: broker.your-company.com:9092
    protocol: kafka

Bad.

asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
channels:
  petAdopted:
    address: pets.adopted

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.asyncapi has the details.

commands:
  lint:
    asyncapi:
      rules:
        servers-defined: off

Related rules

Was this helpful?