asyncapi-3-server-no-trailing-slash
Server host must not end with slash.
- Applies to
host- Selects
$.servers.*.host- 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-server-no-trailing-slash: warn # or off, or another severity
Definition
As defined in @openlint/openlint-rulesets. Functions show by name.
asyncapi-3-server-no-trailing-slash:
description: Server host must not end with slash.
recommended: true
formats:
- AsyncAPI 3.x
given: $.servers.*.host
then:
function: pattern
functionOptions:
notMatch: /$
About this rule
Server host should not have a trailing slash.
Some tooling forgets to strip trailing slashes off when it’s joining the servers.host with channels, and you can get awkward URLs like mqtt://example.com//pets. Best to just strip them off yourself.
Good Example
servers:
- host: mqtt://example.com
Bad Example
servers:
- host: mqtt://example.com/
- host: mqtt://example.com/broker/