asyncapi-3-channel-servers
Channel servers must be defined in the "servers" object.
- Applies to
$ref- Selects
$.channels.*- Function
pattern- Specs
- AsyncAPI 3.x
Use it
This rule ships with OpenLint in spectral:asyncapi. Extending the ruleset turns it on:
extends: spectral:asyncapi
rules:
asyncapi-3-channel-servers: error # or off, or another severity
Definition
As defined in @openlint/openlint-rulesets. Functions show by name.
asyncapi-3-channel-servers:
description: Channel servers must be defined in the "servers" object.
severity: error
recommended: true
formats:
- AsyncAPI 3.x
given: $.channels.*
resolved: false
then:
field: $.servers.*.$ref
function: pattern
functionOptions:
match: '#\/servers\/'
About this rule
Channel servers must be defined in the servers object.
Bad Example
asyncapi: "3.1.0"
info:
title: Awesome API
description: A very well-defined API
version: "1.0"
servers:
production:
url: "stoplight.io"
protocol: "https"
channels:
hello:
servers:
- $ref: #/servers/development
Good Example
asyncapi: "3.1.0"
info:
title: Awesome API
description: A very well-defined API
version: "1.0"
servers:
production:
url: "stoplight.io"
protocol: "https"
channels:
hello:
servers:
- $ref: #/servers/production