Document Require Component Section

document-require-component-section

info experience: consistencyexperience: governance spec: document

{{description}}: {{error}}

The API contract MUST include a ‘components’ section.

Rule definition

The full Spotlight rule — drop it into a ruleset (.spotlight.yaml / .spectral.yaml) and run it with any Spotlight tool.

document-require-component-section:
  title: Document Require Component Section
  reference: https://spotlight-rules.com/spec/rules/openapi/document-require-component-section/
  description: The API contract MUST include a 'components' section.
  message: "{{description}}: {{error}}"
  severity: info
  given: $
  then:
    field: components
    function: truthy
  formats:
    - oas3
  tags:
    - format:openapi
    - spec:document
    - experience:consistency
    - experience:governance
  prompt: "You are editing an OpenAPI document to satisfy the Spotlight API
    governance rule 'document-require-component-section' (Document Require
    Component Section). Requirement: The API contract MUST include a
    'components' section. To fix: Ensure `components` is present and non-empty
    at each matching location. Make the smallest change that satisfies the rule,
    leave all unrelated content, key order, comments, and formatting unchanged,
    and keep the document valid OpenAPI. 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 OpenAPI document to satisfy the Spotlight API governance rule 'document-require-component-section' (Document Require Component Section). Requirement: The API contract MUST include a 'components' section. To fix: Ensure `components` is present and non-empty at each matching location. Make the smallest change that satisfies the rule, leave all unrelated content, key order, comments, and formatting unchanged, and keep the document valid OpenAPI. Return only the complete corrected document, with no commentary.
ArtifactOpenAPI
Applies at (given)$
Severityinfo — educational by default; raise to warn/error to enforce
Referencehttps://spotlight-rules.com/spec/rules/openapi/document-require-component-section/