spectral:asyncapi error on by default

asyncapi-payload

Payloads must be valid against AsyncAPI Schema object.

Applies to
payload
Selects
$.components.messageTraits[?(@.schemaFormat === void 0)].payload
$.components.messages[?(@.schemaFormat === void 0)].payload
$.channels[*][publish,subscribe][?(@property === 'message' && @.schemaFormat === void 0)].payload
Function
asyncApiPayloadValidation
Specs
AsyncAPI 2.x
Message
{{error}}

Use it

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

extends: spectral:asyncapi
rules:
  asyncapi-payload: error   # or off, or another severity

Definition

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

asyncapi-payload:
  description: Payloads must be valid against AsyncAPI Schema object.
  message: '{{error}}'
  severity: error
  recommended: true
  formats:
    - AsyncAPI 2.x
  given:
    - '$.components.messageTraits[?(@.schemaFormat === void 0)].payload'
    - '$.components.messages[?(@.schemaFormat === void 0)].payload'
    - >-
      $.channels[*][publish,subscribe][?(@property === 'message' &&
      @.schemaFormat === void 0)].payload
  then:
    function: asyncApiPayloadValidation

About this rule

When schemaFormat is undefined, the payload object should be valid against the AsyncAPI v2 Schema Object definition.

Sources