Document Require Realistic Examples
document-require-realistic-examples
info
experience: documentationexperience: usability
spec: examples
The {{property}} SHOULD include a real-like example. Add realistic examples to improve API usability.
API design SHOULD include real-like examples for request and response definitions.
Rule definition
The full Spotlight rule — drop it into a ruleset (.spotlight.yaml / .spectral.yaml) and run it with any Spotlight tool.
document-require-realistic-examples:
title: Document Require Realistic Examples
reference: https://spotlight-rules.com/spec/rules/openapi/document-require-realistic-examples/
description: API design SHOULD include real-like examples for request and
response definitions.
message: The {{property}} SHOULD include a real-like example. Add realistic
examples to improve API usability.
severity: info
given: $..[?(@.example || @.examples)]
then:
field: example
function: truthy
formats:
- oas3
tags:
- format:openapi
- spec:examples
- experience:documentation
- experience:usability
prompt: "You are editing an OpenAPI document to satisfy the Spotlight API
governance rule 'document-require-realistic-examples' (Document Require
Realistic Examples). Requirement: API design SHOULD include real-like
examples for request and response definitions. To fix: Ensure `example` is
present and non-empty at each matching location. This rule is evaluated at
the JSONPath `$..[?(@.example || @.examples)]` — 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 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-realistic-examples' (Document Require Realistic Examples). Requirement: API design SHOULD include real-like examples for request and response definitions. To fix: Ensure `example` is present and non-empty at each matching location. This rule is evaluated at the JSONPath `$..[?(@.example || @.examples)]` — 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 OpenAPI. Return only the complete corrected document, with no commentary.
| Artifact | OpenAPI |
|---|---|
| Applies at (given) | $..[?(@.example || @.examples)] |
| Severity | info — educational by default; raise to warn/error to enforce |
| Reference | https://spotlight-rules.com/spec/rules/openapi/document-require-realistic-examples/ |