Asyncapi Message Examples
asyncapi-message-examples · built-in
info
experience: data-modelingexperience: documentationexperience: reliability
spec: channelsspec: messagesspec: components
{{error}}
Examples of message object should follow by “payload” and “headers” schemas.
Rule definition
The full Spotlight rule — drop it into a ruleset (.spotlight.yaml / .spectral.yaml) and run it with any Spotlight tool.
asyncapi-message-examples:
title: Asyncapi Message Examples
reference: https://spotlight-rules.com/spec/rules/asyncapi/asyncapi-message-examples/
description: Examples of message object should follow by "payload" and "headers" schemas.
message: "{{error}}"
severity: info
given:
- $.channels.*.[publish,subscribe].message
- $.channels.*.[publish,subscribe].message.oneOf.*
- $.components.channels.*.[publish,subscribe].message
- $.components.channels.*.[publish,subscribe].message.oneOf.*
- $.components.messages.*
- $.channels.*.[publish,subscribe].message.traits.*
- $.channels.*.[publish,subscribe].message.oneOf.*.traits.*
- $.components.channels.*.[publish,subscribe].message.traits.*
- $.components.channels.*.[publish,subscribe].message.oneOf.*.traits.*
- $.components.messages.*.traits.*
- $.components.messageTraits.*
then:
function: asyncApi2MessageExamplesValidation
tags:
- format:asyncapi
- spec:channels
- spec:messages
- spec:components
- experience:data-modeling
- experience:documentation
- experience:reliability
prompt: "You are editing an AsyncAPI document to satisfy the Spotlight API
governance rule 'asyncapi-message-examples' (Asyncapi Message Examples).
Requirement: Examples of message object should follow by \"payload\" and
\"headers\" schemas. This rule is evaluated at the JSONPath
`$.channels.*.[publish,subscribe].message |
$.channels.*.[publish,subscribe].message.oneOf.* |
$.components.channels.*.[publish,subscribe].message |
$.components.channels.*.[publish,subscribe].message.oneOf.* |
$.components.messages.* | $.channels.*.[publish,subscribe].message.traits.*
| $.channels.*.[publish,subscribe].message.oneOf.*.traits.* |
$.components.channels.*.[publish,subscribe].message.traits.* |
$.components.channels.*.[publish,subscribe].message.oneOf.*.traits.* |
$.components.messages.*.traits.* | $.components.messageTraits.*` — inspect
every location it matches and correct only what violates the rule. Make the
smallest change that satisfies the rule, leave all unrelated content, key
order, comments, and formatting unchanged, and keep the document valid
AsyncAPI. Return only the complete corrected document, with no commentary."
AI fix prompt — send this to Claude, Gemini, or ChatGPT with your artifact to auto-fix this rule
You are editing an AsyncAPI document to satisfy the Spotlight API governance rule 'asyncapi-message-examples' (Asyncapi Message Examples). Requirement: Examples of message object should follow by "payload" and "headers" schemas. This rule is evaluated at the JSONPath `$.channels.*.[publish,subscribe].message | $.channels.*.[publish,subscribe].message.oneOf.* | $.components.channels.*.[publish,subscribe].message | $.components.channels.*.[publish,subscribe].message.oneOf.* | $.components.messages.* | $.channels.*.[publish,subscribe].message.traits.* | $.channels.*.[publish,subscribe].message.oneOf.*.traits.* | $.components.channels.*.[publish,subscribe].message.traits.* | $.components.channels.*.[publish,subscribe].message.oneOf.*.traits.* | $.components.messages.*.traits.* | $.components.messageTraits.*` — inspect every location it matches and correct only what violates the rule. Make the smallest change that satisfies the rule, leave all unrelated content, key order, comments, and formatting unchanged, and keep the document valid AsyncAPI. Return only the complete corrected document, with no commentary.
| Artifact | AsyncAPI |
|---|---|
| Applies at (given) | $.channels.*.[publish,subscribe].message | $.channels.*.[publish,subscribe].message.oneOf.* | $.components.channels.*.[publish,subscribe].message | $.components.channels.*.[publish,subscribe].message.oneOf.* | $.components.messages.* | $.channels.*.[publish,subscribe].message.traits.* | $.channels.*.[publish,subscribe].message.oneOf.*.traits.* | $.components.channels.*.[publish,subscribe].message.traits.* | $.components.channels.*.[publish,subscribe].message.oneOf.*.traits.* | $.components.messages.*.traits.* | $.components.messageTraits.* |
| Severity | info — educational by default; raise to warn/error to enforce |
| Reference | https://spotlight-rules.com/spec/rules/asyncapi/asyncapi-message-examples/ |