spectral:asyncapi error on by default

asyncapi-message-messageId-uniqueness

"messageId" must be unique across all the messages.

Applies to
messageId
Selects
$
Function
asyncApi2MessageIdUniqueness
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-message-messageId-uniqueness: error   # or off, or another severity

Definition

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

asyncapi-message-messageId-uniqueness:
  description: '"messageId" must be unique across all the messages.'
  severity: error
  recommended: true
  formats:
    - AsyncAPI 2.x
  given: $
  then:
    function: asyncApi2MessageIdUniqueness

About this rule

messageId must be unique across all the messages (except those one defined in the components).

Bad Example

channels:
  smartylighting.streetlights.1.0.action.{streetlightId}.turn.on:
    publish:
      message:
        messageId: turnMessage
  smartylighting.streetlights.1.0.action.{streetlightId}.turn.off:
    publish:
      message:
        messageId: turnMessage

Good Example

channels:
  smartylighting.streetlights.1.0.action.{streetlightId}.turn.on:
    publish:
      message:
        messageId: turnOnMessage
  smartylighting.streetlights.1.0.action.{streetlightId}.turn.off:
    publish:
      message:
        messageId: turnOffMessage

Sources