spectral:asyncapi warn on by default

asyncapi-channel-no-trailing-slash

Channel path must not end with slash.

Applies to
channels
Selects
$.channels
Function
pattern
Specs
AsyncAPI 2.x

Use it

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

extends: spectral:asyncapi
rules:
  asyncapi-channel-no-trailing-slash: warn   # or off, or another severity

Definition

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

asyncapi-channel-no-trailing-slash:
  description: Channel path must not end with slash.
  recommended: true
  formats:
    - AsyncAPI 2.x
  given: $.channels
  then:
    field: '@key'
    function: pattern
    functionOptions:
      notMatch: .+\/$

About this rule

Keep trailing slashes off of channel names, as it can cause some confusion. Most messaging protocols will treat example/foo and example/foo/ as different things. Keep in mind that tooling may replace slashes (/) with protocol-specific notation (e.g.: . for AMQP), therefore, a trailing slash may result in an invalid channel name in some protocols.

Sources