Info Require API Identifier

info-require-api-identifier

info experience: discoverabilityexperience: governance spec: document

API must have an unique identifier in x-api-id in #/info/x-api-id.

The #/info/x-api-id field can be used to associate an identifier to an API. This is useful to track an API even when its #/info/title changes.

Rule definition

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

info-require-api-identifier:
  title: Info Require API Identifier
  reference: https://spotlight-rules.com/spec/rules/openapi/info-require-api-identifier/
  description: The `#/info/x-api-id` field can be used to associate an identifier
    to an API. This is useful to track an API even when its `#/info/title`
    changes.
  message: "API must have an unique identifier in x-api-id in #/info/x-api-id."
  severity: info
  given: $
  then:
    field: info.x-api-id
    function: truthy
  tags:
    - format:openapi
    - spec:document
    - experience:discoverability
    - experience:governance
  prompt: "You are editing an OpenAPI document to satisfy the Spotlight API
    governance rule 'info-require-api-identifier' (Info Require API Identifier).
    Requirement: The `#/info/x-api-id` field can be used to associate an
    identifier to an API. This is useful to track an API even when its
    `#/info/title` changes. To fix: Ensure `info.x-api-id` 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 'info-require-api-identifier' (Info Require API Identifier). Requirement: The `#/info/x-api-id` field can be used to associate an identifier to an API. This is useful to track an API even when its `#/info/title` changes. To fix: Ensure `info.x-api-id` 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/info-require-api-identifier/