Component Asyncapi Message Require Contenttype
component-asyncapi-message-require-contenttype
info
experience: consistencyexperience: data-modeling
spec: components
Message should declare a contentType.
Messages should declare a contentType (e.g. application/json).
Rule definition
The full Spotlight rule — drop it into a ruleset (.spotlight.yaml / .spectral.yaml) and run it with any Spotlight tool.
component-asyncapi-message-require-contenttype:
title: Component Asyncapi Message Require Contenttype
reference: https://spotlight-rules.com/spec/rules/asyncapi/component-asyncapi-message-require-contenttype/
description: Messages should declare a contentType (e.g. application/json).
message: Message should declare a contentType.
given: $.components.messages[*]
severity: info
then:
field: contentType
function: truthy
tags:
- format:asyncapi
- spec:components
- experience:consistency
- experience:data-modeling
prompt: "You are editing an AsyncAPI document to satisfy the Spotlight API
governance rule 'component-asyncapi-message-require-contenttype' (Component
Asyncapi Message Require Contenttype). Requirement: Messages should declare
a contentType (e.g. application/json). To fix: Ensure `contentType` is
present and non-empty at each matching location. This rule is evaluated at
the JSONPath `$.components.messages[*]` — 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 'component-asyncapi-message-require-contenttype' (Component Asyncapi Message Require Contenttype). Requirement: Messages should declare a contentType (e.g. application/json). To fix: Ensure `contentType` is present and non-empty at each matching location. This rule is evaluated at the JSONPath `$.components.messages[*]` — 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) | $.components.messages[*] |
| Severity | info — educational by default; raise to warn/error to enforce |
| Reference | https://spotlight-rules.com/spec/rules/asyncapi/component-asyncapi-message-require-contenttype/ |