This prompt is designed for API designers, technical writers, and platform engineers who need to verify that human-readable API documentation (Markdown, HTML, or a documentation portal) accurately reflects the machine-readable OpenAPI specification. The core job-to-be-done is preventing documentation drift by producing a structured diff report that flags mismatches in endpoint descriptions, parameter tables, schema definitions, and example payloads before they reach end users. The ideal user has access to both a valid OpenAPI spec and the rendered documentation, and needs a repeatable, automatable gate to ensure the two stay synchronized.
Prompt
OpenAPI Spec-to-Documentation Consistency Prompt

When to Use This Prompt
Define the job, reader, and constraints for the OpenAPI spec-to-documentation consistency check.
Use this prompt as a pre-release gate in your documentation workflow or as part of a CI/CD pipeline that triggers on spec changes or documentation deployments. The prompt expects two primary inputs: the raw OpenAPI specification (JSON or YAML) and the extracted text of the documentation page or section being audited. It works best when the documentation has clear endpoint boundaries—such as distinct sections for each operation—and when the spec is the authoritative source of truth. The output should be a structured report that can be parsed by downstream tooling, with severity levels for each finding so teams can block releases on critical mismatches or log warnings for minor inconsistencies.
Do not use this prompt when you lack a valid, complete OpenAPI spec, when the documentation format is purely unstructured prose without clear endpoint or parameter boundaries, or when you need runtime behavioral validation rather than spec-to-doc consistency. This prompt checks whether the docs say what the spec says—it does not verify whether the API actually behaves as specified. For runtime validation, pair this with a separate behavioral testing harness. Additionally, if your documentation is auto-generated from the spec, this prompt may produce false positives for intentional formatting differences; in those cases, a direct spec-to-render comparison tool is more appropriate than an LLM-based audit.
Use Case Fit
Where this prompt works, where it fails, and the operational risks to manage before wiring it into a documentation pipeline.
Strong Fit: Spec-First API Teams
Use when: your team maintains an OpenAPI spec as the source of truth and generates reference docs from it. The prompt excels at catching drift between the spec and the rendered documentation. Guardrail: Run this prompt after every spec change and before every docs publish. Treat the diff report as a release gate.
Weak Fit: Undocumented or Spec-Less APIs
Avoid when: no OpenAPI spec exists, or the spec is so incomplete that it does not represent the real API surface. The prompt compares two artifacts; it cannot invent a spec from runtime behavior. Guardrail: Use an API traffic capture or code-annotation-to-spec tool first, then run this consistency check.
Required Inputs
Risk: incomplete inputs produce false negatives. The prompt needs the full OpenAPI spec (YAML/JSON) and the rendered documentation text for the same API version. Guardrail: Validate that both inputs reference the same API version and that the spec passes OpenAPI linting before running the consistency check. Reject mismatched versions.
Operational Risk: Large Specs Exceed Context
Risk: multi-file or very large OpenAPI specs can overflow the context window, causing truncated analysis or hallucinated diffs. Guardrail: Chunk the spec by tag or path group and run the prompt per endpoint family. Aggregate results in the application layer. Set a hard token budget and fail gracefully if exceeded.
Operational Risk: False Positives from Intentional Differences
Risk: documentation may intentionally simplify, reorder, or add narrative context that does not appear in the spec. The prompt may flag these as inconsistencies. Guardrail: Add a [CONSTRAINTS] block listing acceptable divergence categories (e.g., prose introductions, usage notes, conceptual overviews). Post-process diffs to suppress known-acceptable patterns.
Not a Replacement for Contract Testing
Risk: this prompt checks documentation against a spec, not the spec against the live API. A correct-but-wrong spec will produce a clean consistency report while the API itself is broken. Guardrail: Pair this prompt with contract tests that validate the spec against actual API responses. The consistency check is one link in a three-way chain: live API → spec → docs.
Copy-Ready Prompt Template
A reusable prompt that diffs an OpenAPI specification against human-readable documentation and returns a structured consistency report.
This prompt template is designed to be pasted directly into your AI harness. It instructs the model to act as an API documentation auditor, comparing a provided OpenAPI specification against a set of documentation pages. The model must identify discrepancies in endpoint descriptions, parameter tables, request/response schemas, and example payloads, then output a structured JSON diff report. All dynamic inputs are represented as square-bracket placeholders, which you must replace with real data before execution. The output format is strictly JSON to enable direct ingestion by downstream validation scripts, CI/CD pipelines, or review dashboards.
textYou are an API documentation auditor. Your task is to compare the provided OpenAPI specification against the provided human-readable documentation and produce a structured consistency report. ## INPUTS - OpenAPI Specification: [OPENAPI_SPEC] - Documentation Pages: [DOCUMENTATION_PAGES] ## OUTPUT_SCHEMA Return a single JSON object conforming to this structure: { "summary": { "total_endpoints_in_spec": <integer>, "total_endpoints_documented": <integer>, "total_discrepancies": <integer>, "critical_discrepancies": <integer>, "warning_discrepancies": <integer> }, "discrepancies": [ { "id": "<string, unique discrepancy identifier>", "severity": "<critical | warning>", "category": "<missing_endpoint | missing_parameter | parameter_type_mismatch | missing_response_schema | schema_field_mismatch | example_payload_error | description_mismatch | missing_error_code | other>", "location": { "spec_path": "<string, JSON pointer to the relevant part of the OpenAPI spec>", "doc_reference": "<string, section heading or paragraph identifier in the documentation>" }, "spec_value": "<string, the correct value from the OpenAPI spec>", "doc_value": "<string, the conflicting value found in the documentation>", "description": "<string, human-readable explanation of the discrepancy>", "suggested_fix": "<string, actionable suggestion to resolve the discrepancy>" } ], "undocumented_endpoints": [ { "path": "<string>", "method": "<GET | POST | PUT | DELETE | PATCH>", "spec_summary": "<string, the endpoint's summary from the spec>" } ], "stale_documentation": [ { "doc_reference": "<string>", "claimed_endpoint": "<string>", "issue": "<string, e.g., endpoint not found in spec>" } ] } ## CONSTRAINTS - [CONSTRAINTS] ## INSTRUCTIONS 1. Parse the OpenAPI specification to extract all paths, methods, parameters, request bodies, response schemas, and examples. 2. Parse the documentation pages to identify all described endpoints, parameters, schemas, and examples. 3. For every endpoint in the spec, verify its presence and accuracy in the documentation. 4. For every endpoint in the documentation, verify it exists in the spec. 5. Flag any mismatch as a discrepancy with the appropriate severity. 6. If no documentation is provided for an endpoint, list it under `undocumented_endpoints`. 7. If documentation describes an endpoint not in the spec, list it under `stale_documentation`. 8. Output ONLY the JSON object. No other text.
To adapt this template, replace the placeholders with your specific context. [OPENAPI_SPEC] should contain the full JSON or YAML text of your specification. [DOCUMENTATION_PAGES] should contain the full text of the documentation you are auditing, with clear section markers if possible. The [CONSTRAINTS] placeholder is where you inject specific rules, such as ignoring certain deprecated endpoints, focusing only on externally facing APIs, or setting a custom severity threshold for parameter description mismatches. After running the prompt, always validate the output against the provided JSON schema before passing it to any automated system. For high-stakes releases, a human reviewer should spot-check a sample of flagged discrepancies to ensure the model did not hallucinate a mismatch due to ambiguous documentation language.
Prompt Variables
Required and optional inputs for the OpenAPI Spec-to-Documentation Consistency Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to verify the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
[OPENAPI_SPEC] | The source OpenAPI specification to use as ground truth for the consistency check | openapi: 3.1.0 info: title: Payments API version: 2.3.0 paths: /charges: post: summary: Create a charge | Parse as valid JSON or YAML. Validate against OpenAPI 3.0 or 3.1 schema. Reject if spec fails structural validation. Must contain at least one path item. | ||||||||
[DOCUMENTATION_CONTENT] | The human-readable documentation to audit against the OpenAPI spec | Create a ChargePOST /charges Creates a new charge object. Parameters
| Must be non-empty string. Accepts Markdown, HTML, or plain text. Strip irrelevant navigation chrome before passing. Minimum 100 characters to avoid empty-doc false positives. | ||||||||
[COMPARISON_SCOPE] | Defines which parts of the spec and docs to compare | endpoints, parameters, schemas, examples | Must be a comma-separated list from allowed values: endpoints, parameters, schemas, examples, auth, errors, headers, descriptions. Default to all if omitted. Reject unknown scope values. | ||||||||
[OUTPUT_FORMAT] | Controls the structure of the diff report | markdown_table | Must be one of: markdown_table, json_diff, structured_report. Default to structured_report if omitted. Reject unrecognized format strings. | ||||||||
[SEVERITY_THRESHOLD] | Minimum severity level to include in the report | warning | Must be one of: info, warning, error, critical. Items below this threshold are excluded from output. Default to warning if omitted. | ||||||||
[IGNORED_ENDPOINTS] | Endpoints to exclude from the comparison | ["/health", "/internal/metrics"] | Must be a valid JSON array of path strings. Each path must match an existing path in [OPENAPI_SPEC] or emit a pre-flight warning. Empty array is valid. | ||||||||
[STYLE_GUIDE_RULES] | Optional documentation style rules to check alongside spec consistency | {"parameter_table_columns": ["Name", "Type", "Required", "Description"], "require_examples": true} | Must be valid JSON object. Null allowed. If provided, each rule key must be from allowed set: parameter_table_columns, require_examples, description_min_length, code_sample_language, heading_hierarchy. Unknown keys trigger pre-flight warning. |
Implementation Harness Notes
How to wire the OpenAPI spec-to-documentation consistency prompt into a CI/CD pipeline or documentation review workflow.
This prompt is designed to operate as a diff engine between a source-of-truth OpenAPI specification and the rendered developer documentation. The implementation harness should treat the prompt as a comparison function: input the spec and the doc page, receive a structured inconsistency report, and then decide what to do with each finding. Because the output is a structured diff rather than freeform prose, the harness must validate the output schema before surfacing results to technical writers or API designers.
Wire the prompt into a CI/CD check that triggers on documentation pull requests or scheduled spec snapshots. The harness should: (1) fetch the latest OpenAPI spec from the canonical source (e.g., a published openapi.yaml or a build artifact); (2) extract the relevant documentation page from the PR diff or the live docs site; (3) populate the [OPENAPI_SPEC] and [DOCUMENTATION_PAGE] placeholders; (4) call the model with response_format set to the expected JSON schema; (5) validate the returned JSON against the schema, retrying once on parse failure; (6) filter findings by severity threshold (e.g., only error and warning for CI blocking, info for review queues); and (7) post the filtered report as a PR comment or ticket. For high-stakes APIs where documentation errors cause integration failures, require human approval on error-level findings before merging.
Common failure modes in the harness include: the model hallucinating parameter names not present in either the spec or the doc; the output exceeding token limits for large specs (mitigate by chunking the spec by endpoint or tag group); and false positives when the documentation intentionally simplifies spec details for readability. Build eval assertions that compare the model's flagged inconsistencies against a golden dataset of known spec-doc mismatches, measuring precision and recall. Log every comparison run with the spec version, doc version, model version, and the raw output for auditability. Start with a non-blocking advisory mode before promoting the check to a required CI gate.
Expected Output Contract
Each field the model must return for the OpenAPI spec-to-documentation consistency diff report, with its type, requirement status, and a concrete validation rule you can enforce in your harness before the output reaches a reviewer.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
diff_report | JSON object | Top-level key must exist and parse as valid JSON. Schema check: object with required keys 'summary', 'findings', 'meta'. | |
summary.total_endpoints_checked | integer | Must be >= 0. Parse check: non-negative integer. If 0, findings array must be empty. | |
summary.consistency_score | number | Must be between 0.0 and 1.0 inclusive. Parse check: float. If 1.0, no findings may have severity 'high' or 'critical'. | |
findings | array of objects | Schema check: each element must contain 'id', 'severity', 'location', 'expected', 'actual', 'recommendation'. Array may be empty only if consistency_score is 1.0. | |
findings[].id | string | Format check: must match pattern FINDING-[0-9]{4}. Must be unique within the array. | |
findings[].severity | enum string | Enum check: must be one of 'critical', 'high', 'medium', 'low'. No other values allowed. | |
findings[].location.spec_ref | string | Must contain a valid JSON Pointer or path expression referencing the OpenAPI spec (e.g., '#/paths/~1users/get/parameters/0/name'). Parse check: starts with '#'. | |
findings[].location.doc_ref | string | Must contain a section heading, anchor, or URL fragment identifying the documentation location. Non-empty string check. | |
findings[].expected | string | Must quote or summarize the value from the OpenAPI spec. Non-empty string. If spec value is null, expected must be the literal string 'null'. | |
findings[].actual | string | Must quote or summarize the value found in the documentation. Non-empty string. If documentation omits the element, actual must be the literal string '[MISSING]'. | |
findings[].recommendation | string | Must be a complete, actionable sentence describing the fix. Non-empty string. Must not contain unresolved placeholders or model uncertainty language like 'maybe' or 'consider'. | |
meta.generated_at | ISO 8601 timestamp | Format check: must parse as valid ISO 8601 datetime string. Must include timezone offset. | |
meta.spec_version | string | Must match the 'info.version' field from the input OpenAPI spec exactly. String equality check against source spec. |
Common Failure Modes
What breaks first when you ask a model to compare an OpenAPI spec against human-readable documentation, and how to guard against it.
Spec-Doc Drift from Stale Inputs
What to watch: The model compares an old version of the spec against the latest docs (or vice versa), producing a diff report full of false positives. Guardrail: Always inject a [SPEC_VERSION] and [DOC_VERSION] variable into the prompt and reject the run if they don't match the expected release tag.
Schema Deep-Path Omission
What to watch: The model correctly flags top-level endpoint changes but silently ignores deeply nested schema differences (e.g., a property inside an array inside a $ref). Guardrail: Instruct the model to recursively resolve and compare all $ref nodes. Validate the output by spot-checking a known nested field that was intentionally broken in a test fixture.
Example Payload Hallucination
What to watch: The model reports a mismatch because it hallucinated a missing example in the spec, or it fails to notice that the doc's example payload violates the spec's minLength constraint. Guardrail: Add a strict rule: 'Only flag an example mismatch if you can quote the exact line from the spec that contradicts it.' Use a JSON Schema validator on the doc's examples as a pre-processing step.
Description Semantics vs. Literal Text
What to watch: The model flags a 'mismatch' because the spec says 'unique identifier' and the doc says 'primary key,' even though they are semantically identical. Guardrail: Provide a [SYNONYM_MAP] or a rule that states: 'Do not flag differences in phrasing unless the technical constraint (type, required, enum) is different.'
Enum Value Ordering Sensitivity
What to watch: The model reports a breaking change because the enum values in the doc are listed in a different order than the spec, even though order is irrelevant for the API contract. Guardrail: Explicitly instruct the model to treat enum lists as unordered sets for comparison purposes, unless the spec defines them as an ordered tuple.
Context Window Truncation on Large Specs
What to watch: A large OpenAPI spec exceeds the context window, causing the model to silently drop the last 30 endpoints from the comparison and report a false 'clean' result. Guardrail: Chunk the spec by endpoint path and run the comparison in parallel batches. Implement a final aggregator check that verifies the total endpoint count in the report matches the spec's path count.
Evaluation Rubric
Use this rubric to evaluate the quality of the consistency report before integrating it into your CI/CD pipeline. Each criterion targets a specific failure mode of spec-to-documentation diffing.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Endpoint Coverage Completeness | Every path and method in [OPENAPI_SPEC] appears in the diff report with a status of matched, missing, or undocumented | Report omits a path or method present in the spec; diff count mismatches the number of spec endpoints | Parse the report and the spec; assert set equality on all path+method combinations |
Parameter Field-Level Accuracy | For each endpoint, every parameter in the spec is compared against documentation; type, required flag, and description mismatches are flagged individually | A documented parameter with a wrong type is marked as matched; a missing required flag is not flagged | Select 5 random endpoints; manually verify that all parameter mismatches in the spec are present in the report |
Schema Property Drift Detection | For each request/response schema, every property difference between spec and docs is captured: missing properties, extra properties, type changes, and constraint mismatches | A property that changed from integer to number is not flagged; an added required field is omitted from the diff | Inject a known schema mismatch into a test fixture; confirm the report catches it with the correct severity |
Example Payload Validation | Every example in the documentation is checked against the spec schema; invalid examples are flagged with the specific validation error | An example that violates the schema is marked as valid; a valid example is incorrectly flagged | Use a JSON Schema validator on each documented example; cross-reference failures with report findings |
Severity Classification Consistency | Every finding is assigned a severity (critical, high, medium, low) based on a defined policy: type mismatches are critical, description drift is low, missing optional params are medium | A type mismatch is classified as low; a missing endpoint is classified as medium | Define a severity policy in [CONSTRAINTS]; run 10 known findings through the prompt and verify severity labels match the policy |
False Positive Rate on Conditional Content | Conditional or version-specific documentation is not flagged as a mismatch when the spec describes the current version behavior | A note saying 'deprecated in v3' is flagged as a mismatch against a v3 spec that removed the field | Include conditional documentation in test fixtures; verify the report either excludes these or marks them as informational, not errors |
Report Structure and Machine-Readability | Output strictly conforms to [OUTPUT_SCHEMA]; every finding has endpoint, location, expected, actual, and severity fields; the report is parseable as valid JSON | Output is missing required fields; JSON is malformed; findings are in free-text instead of structured objects | Validate output against the JSON Schema defined in [OUTPUT_SCHEMA]; reject on parse errors or missing required fields |
Actionability of Findings | Each finding includes enough context to locate the issue: documentation page or section, spec path, and the exact mismatch; a human can act without re-investigating | Finding says 'parameter mismatch' without naming the parameter or endpoint; location is too vague to find | Sample 5 findings; ask a developer unfamiliar with the API to locate the issue in under 2 minutes using only the report |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Add a strict JSON output schema with endpoint, field, spec_value, doc_value, severity, and recommendation fields. Wrap the prompt in a harness that validates output against the schema, retries on parse failure, and logs every comparison.
codeReturn a JSON array of inconsistency objects matching [OUTPUT_SCHEMA]. Each object must include: endpoint path, field name, value in spec, value in docs, severity (critical/warning/info), and a one-sentence recommendation.
Watch for
- Silent format drift when model changes versions
- Missing
severityclassifications causing noisy alerts - Large specs exceeding context window—chunk by endpoint

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us