spectral:asyncapi error on by default

asyncapi-3-headers-schema-type-object

Headers schema type must be "object".

Applies to
headers
Selects
$.components.messageTraits.*.headers
$.components.messages.*.headers
$.channels.*.messages.*.headers
$.channels.*.messages.*.traits[*].headers
Function
schema
Specs
AsyncAPI 3.x
Message
Headers schema type must be "object" ({{error}}).

Use it

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

extends: spectral:asyncapi
rules:
  asyncapi-3-headers-schema-type-object: error   # or off, or another severity

Definition

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

asyncapi-3-headers-schema-type-object:
  description: Headers schema type must be "object".
  message: 'Headers schema type must be "object" ({{error}}).'
  severity: error
  recommended: true
  formats:
    - AsyncAPI 3.x
  given:
    - $.components.messageTraits.*.headers
    - $.components.messages.*.headers
    - $.channels.*.messages.*.headers
    - '$.channels.*.messages.*.traits[*].headers'
  then:
    function: schema
    functionOptions:
      allErrors: true
      schema:
        type: object
        properties:
          type:
            enum:
              - object
        required:
          - type

About this rule

The schema definition of the application headers must be of type “object”.

Sources