spectral:asyncapi error on by default

asyncapi-schema-examples

Examples must be valid against their defined schema.

Applies to
examples
Selects
$.components.schemas.*.examples^
$.components.parameters.*.schema.examples^
$.channels.*.parameters.*.schema.examples^
Function
asyncApiSchemaValidation
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-schema-examples: error   # or off, or another severity

Definition

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

asyncapi-schema-examples:
  description: Examples must be valid against their defined schema.
  message: '{{error}}'
  severity: error
  recommended: true
  formats:
    - AsyncAPI 2.x
  given:
    - $.components.schemas.*.examples^
    - $.components.parameters.*.schema.examples^
    - $.channels.*.parameters.*.schema.examples^
  then:
    function: asyncApiSchemaValidation
    functionOptions:
      type: examples

About this rule

Values of the examples array should be valid against the schema they decorate.

Sources