API platform engineers and governance teams use this prompt to perform a structural review of an OpenAPI specification against the rules of version 3.0 or 3.1. The job-to-be-done is a fast, human-readable first pass that catches missing required fields, invalid $ref targets, schema keyword misuse, and version-specific constraint violations before the spec reaches a deterministic linter like Spectral. The ideal user is an API designer or platform engineer who has a raw or draft OpenAPI document and needs categorized feedback with fix suggestions, not just a pass/fail result.
Prompt
OpenAPI Specification Validation Against 3.0/3.1 Rules Prompt

When to Use This Prompt
Determine if an LLM-based structural review is the right first pass before deterministic linting of an OpenAPI specification.
This prompt is most effective when you need explanations alongside validation output. For example, if a $ref points to a missing component, the report should identify the broken reference path and suggest the correct component name, rather than just emitting a generic error code. Use this when you are iterating on a spec and want guidance on why something is invalid under the 3.0 or 3.1 structural rules. The prompt expects a complete OpenAPI document as input and produces a structured report with errors, warnings, and fix_suggestions arrays, each entry referencing the exact JSON path and the violated rule.
Do not use this prompt as a replacement for deterministic validation in CI/CD pipelines. It is not suitable for enforcing organization-specific style rules, checking example payload conformance, or validating runtime behavior. After running this prompt, always follow up with a deterministic linter and schema validator to catch any remaining mechanical violations. For high-risk API surfaces, require human review of the categorized report before accepting automated fix suggestions.
Use Case Fit
Where this prompt works, where it fails, and what you must provide before running it in a harness.
Good Fit: Pre-Commit and CI Validation
Use when: you need automated, rule-based validation of an OpenAPI 3.0 or 3.1 spec before it merges. The prompt excels at catching structural violations like missing required fields, invalid $ref targets, and schema keyword misuse. Guardrail: Run this prompt as a CI check with a strict JSON output schema so the harness can parse errors programmatically and block the merge on critical violations.
Bad Fit: Semantic API Design Review
Avoid when: you need feedback on whether your API is well-designed, RESTful, or intuitive. This prompt validates structural rules, not naming conventions, resource modeling, or business logic consistency. Guardrail: Pair this prompt with a separate design review prompt or human review checklist for semantic concerns. Do not treat a passing validation report as a design approval.
Required Input: A Complete or Partial OpenAPI Spec
What to watch: The prompt requires a valid YAML or JSON OpenAPI document as input. Feeding it a fragment, a single schema, or a Swagger 2.0 spec without conversion will produce misleading errors or false positives. Guardrail: Pre-validate that the input is parseable as YAML/JSON and includes an openapi version field. If the input is Swagger 2.0, run a conversion prompt first.
Operational Risk: Model Hallucination on Spec Semantics
What to watch: The model may invent violations that don't exist or miss real ones, especially with deeply nested $ref chains, complex oneOf/anyOf structures, or custom extensions. Guardrail: Always pair this prompt with a deterministic linting tool like Spectral or a native OpenAPI validator as a second pass. Treat the model output as a fast first scan, not the final authority.
Operational Risk: Large Spec Token Limits
What to watch: OpenAPI specs with many endpoints, large schemas, or extensive examples can exceed context windows, causing truncation or degraded validation quality. Guardrail: For specs over ~20K tokens, split the spec into smaller components (paths, schemas, parameters) and validate each independently, or use a model with a larger context window and monitor for mid-report truncation.
Good Fit: Version-Specific Rule Enforcement
What to watch: OpenAPI 3.0 and 3.1 have different rules for exclusiveMinimum, type arrays, nullable, and JSON Schema compliance. A generic validator may miss version-specific violations. Guardrail: Explicitly include the target version in the prompt instructions and validate that the output report categorizes errors by the correct specification version. Cross-check a sample of findings against the official specification.
Copy-Ready Prompt Template
A copy-ready prompt for validating OpenAPI specifications against 3.0/3.1 structural rules, producing a categorized error and warning report with fix suggestions.
This prompt template is designed to be pasted directly into your AI harness or orchestration layer. It instructs the model to act as a strict OpenAPI specification validator, analyzing the provided spec for structural compliance against version 3.0 or 3.1 rules. The prompt is structured to produce a machine-readable JSON report, making it suitable for integration into CI/CD pipelines, pre-commit hooks, or API governance workflows. Before execution, you must replace all square-bracket placeholders with the actual spec content, target version, and any custom organizational rules you want enforced.
textYou are an expert OpenAPI specification validator. Your task is to analyze the provided OpenAPI specification for strict compliance with the structural rules of version [TARGET_VERSION]. # INPUT SPECIFICATION [OPENAPI_SPEC] # CUSTOM RULES (Optional) [CUSTOM_RULES] # VALIDATION INSTRUCTIONS 1. Parse the specification and confirm its declared OpenAPI version. 2. Validate every object, property, and structure against the [TARGET_VERSION] specification rules. Pay special attention to: - Missing required fields (e.g., `info`, `paths`, `openapi`). - Invalid `$ref` targets and circular references. - Incorrect data types and format values. - Schema keyword misuse (e.g., `nullable` in 3.1, `example` vs `examples`). - Security scheme and scope definition errors. - Parameter and request body structural violations. - Response and header object schema errors. 3. Apply any provided [CUSTOM_RULES] as additional checks. 4. Categorize every finding as either `error` (spec is invalid) or `warning` (best practice violation or deprecation). 5. For each finding, provide the exact JSON path, a clear description of the problem, the relevant spec rule reference, and a suggested fix. # OUTPUT FORMAT Return a single JSON object with the following structure. Do not include any text outside the JSON object. { "spec_version_detected": "string", "target_version": "[TARGET_VERSION]", "summary": { "total_errors": number, "total_warnings": number, "is_valid": boolean }, "findings": [ { "severity": "error | warning", "path": "$.paths./users.get.responses.200", "rule_reference": "OpenAPI 3.1 Section 4.8.9", "description": "string", "suggested_fix": "string" } ] }
To adapt this template, replace [TARGET_VERSION] with either 3.0.3 or 3.1.0 to control which rule set the model applies. The [OPENAPI_SPEC] placeholder should be replaced with the full YAML or JSON string of your specification. The [CUSTOM_RULES] placeholder is optional; you can inject organizational standards like 'All paths must use kebab-case' or 'Every operation must have a 429 response for rate limiting.' If you have no custom rules, remove that section or replace it with 'None.' For high-stakes validation in CI/CD, always pair this prompt with a deterministic linter like Spectral to catch any model hallucinations in the rule reference field.
Prompt Variables
Placeholders required by the OpenAPI Specification Validation prompt. Replace each with a concrete value before calling the model. Validation notes describe how the harness should check the input before it reaches the prompt.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[OPENAPI_SPEC] | The raw OpenAPI document to validate, as a JSON or YAML string | openapi: "3.1.0" info: title: Petstore version: "1.0.0" paths: {} | Parse check: must be valid JSON or YAML. Schema check: must contain an openapi field with a string value. Null not allowed. |
[TARGET_VERSION] | The OpenAPI specification version to validate against | "3.1.0" | Enum check: must be "3.0.3" or "3.1.0". Null not allowed. Mismatch with [OPENAPI_SPEC] openapi field should trigger a pre-prompt warning. |
[VALIDATION_SCOPE] | Scope of rules to apply: structural only, or structural plus semantic best practices | "structural-and-semantic" | Enum check: must be "structural-only" or "structural-and-semantic". Default to "structural-only" if null or missing. |
[KNOWN_SCHEMA_REGISTRY] | Optional list of external $ref targets that are known to be resolvable, to suppress false-positive unresolved-ref errors | ["https://example.com/schemas/pet.json", "#/components/schemas/Error"] | Parse check: must be a JSON array of strings if provided. Null allowed. Each entry must be a valid URI or JSON Pointer fragment. |
[CUSTOM_RULES] | Optional array of additional validation rules beyond the spec-defined structural rules | [{"id":"no-numeric-enums","description":"Flag enum values that are numeric rather than string","severity":"warning"}] | Parse check: must be a JSON array of objects with id, description, and severity fields if provided. Null allowed. Severity must be "error" or "warning". |
[OUTPUT_FORMAT] | Desired output structure for the validation report | "categorized-json" | Enum check: must be "categorized-json", "flat-json", or "markdown-table". Default to "categorized-json" if null. |
[LOCALE] | Language for human-readable error descriptions and fix suggestions | "en" | Parse check: must be a valid BCP 47 language tag string. Default to "en" if null. Null allowed. |
Implementation Harness Notes
How to wire the OpenAPI validation prompt into a CI pipeline, API gateway, or design review workflow with retries, structured output parsing, and human escalation gates.
This prompt is designed to operate as a deterministic linting and review step inside a broader API governance pipeline. It should not be the only validation gate. Instead, wire it after structural parsing (e.g., YAML/JSON syntax checks) and before Spectral or custom lint rules. The model receives a raw OpenAPI 3.0 or 3.1 spec string and returns a structured JSON report of categorized errors, warnings, and fix suggestions. The application layer is responsible for extracting that JSON, validating its schema, and deciding which findings block a merge or deploy.
Integration pattern: Wrap the prompt in a function that accepts [OPENAPI_SPEC_STRING] and [OPENAPI_VERSION] (either 3.0.x or 3.1.x). Set [CONSTRAINTS] to enforce the output schema and limit the report to structural rule violations only—no stylistic opinions unless explicitly requested. On the model side, use a low-temperature setting (0.0–0.1) and request JSON output with a defined schema. On the application side, parse the response and validate it against a JSON Schema that expects errors and warnings arrays, each containing path, rule_id, message, and suggestion fields. If the model output fails schema validation, retry once with a repair prompt that includes the raw response and the schema violation details. After two failures, log the raw output and escalate for human review.
Tool use and RAG considerations: For OpenAPI 3.0 vs 3.1 rule differences, embed the relevant specification excerpts directly in [CONTEXT] rather than relying on the model's training data. Include the exact rules for $ref sibling handling (allowed in 3.1, forbidden in 3.0), exclusiveMinimum/exclusiveMaximum type changes, nullable deprecation, and path-level summary/description requirements. If your organization has additional internal rules (e.g., required x- extensions, naming conventions), add those as explicit constraints. Do not use RAG for the spec rules themselves—they are small enough to inline. For large specs exceeding context windows, chunk by path item or schema component and run validation per chunk, then merge results in the application layer.
Failure modes to instrument: Watch for (1) the model hallucinating rule violations that don't exist in the spec, (2) missing real violations because the spec section wasn't in the model's attention window, (3) producing valid JSON that doesn't match the expected output schema, and (4) timing out on very large specs. Log every validation run with the spec version, spec size in bytes, number of findings, and whether the output passed schema validation. For high-risk API surfaces (auth endpoints, payment paths, PII-carrying schemas), require a human to confirm any error marked as severity: critical before the spec is published. This prompt is a fast first pass, not a replacement for deterministic schema validation or security review.
Expected Output Contract
Defines the structure and validation rules for the model's response when validating an OpenAPI specification. Use this contract to parse, validate, and route the output in your application harness.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
validation_report | object | Top-level key must be an object. Parse check: confirm the response is a valid JSON object with this root key. | |
validation_report.spec_version | string (enum) | Must be one of '3.0.x' or '3.1.x'. Schema check: validate against the detected version of the input spec. | |
validation_report.errors | array[object] | Must be an array. If empty, the array must be present but contain zero elements. Schema check: validate array type. | |
validation_report.errors[].path | string (JSON Pointer) | Must be a valid JSON Pointer (RFC 6901) to the violating element in the source spec, e.g., '/paths/~1users/get/responses'. | |
validation_report.errors[].rule_id | string | Must match a known rule identifier from the OpenAPI specification (e.g., 'oas3-schema-required', 'oas3-valid-media-type'). | |
validation_report.errors[].message | string | Must be a non-empty string describing the violation. Parse check: string length > 0. | |
validation_report.errors[].severity | string (enum) | Must be one of 'error', 'warning', or 'info'. Schema check: validate against the allowed enum values. | |
validation_report.errors[].suggestion | string | If present, must be a non-empty string with a concrete fix suggestion. Null allowed. Parse check: if not null, string length > 0. |
Common Failure Modes
When validating OpenAPI specs against 3.0/3.1 rules, these failures surface first in production. Each card identifies a specific breakage pattern and the guardrail that catches it before downstream consumers break.
Phantom $ref Targets
What to watch: The spec references a component that doesn't exist in #/components/schemas/, #/components/parameters/, or #/components/responses/. The model hallucinates plausible schema names or copies refs from a different spec version. Guardrail: Run a pre-validation pass that resolves every $ref pointer against the spec's own component tree and rejects any spec with dangling references before the model sees it.
Schema Keyword Misuse Across Versions
What to watch: The model applies 3.1 keywords like prefixItems or contains to a 3.0 spec, or uses the 3.0 nullable keyword in a 3.1 spec where it's been removed. The output passes casual review but fails strict tooling. Guardrail: Pin the target OAS version in the prompt and include a version-specific keyword allowlist. Run a Spectral lint with the correct OAS ruleset as a post-generation gate.
Missing Required Fields in Responses
What to watch: The model documents a 200 response but omits content, schema, or description fields required by the spec. Downstream code generators and doc renderers produce empty or broken output. Guardrail: Validate every response object against the OAS structural schema before accepting the output. Flag any response entry missing description or with an empty content map.
Enum-String Type Confusion
What to watch: The model declares a property as type: string but adds an enum of integers, or vice versa. OpenAPI validators reject the mismatch, but the model doesn't self-correct unless explicitly prompted. Guardrail: Add a post-processing check that compares the declared type against the actual enum value types. Reject any spec where enum members don't match the schema's type field.
Discriminator Without Mapping
What to watch: The model adds a discriminator property to a oneOf or anyOf schema but omits the required mapping object or references schemas that don't contain the discriminator property. Code generators can't resolve the variant. Guardrail: For every discriminator in the spec, verify that propertyName exists in each mapped schema and that all mapping values resolve to valid component references.
Security Scheme Scope Drift
What to watch: The model documents OAuth2 scopes on an operation that aren't declared in the global components/securitySchemes definition, or references a security scheme name that doesn't exist. API gateways reject the spec at deploy time. Guardrail: Cross-reference every security requirement on every operation against the declared security schemes. Reject any scope or scheme name that isn't defined in components/securitySchemes.
Evaluation Rubric
Criteria for evaluating the quality of the OpenAPI validation report before integrating it into a CI pipeline or API governance workflow. Each row defines a pass standard, a failure signal, and a concrete test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Structural completeness | Report contains a top-level | Report is missing one or both required arrays, or arrays are present but empty when the spec has known violations | Parse the output as JSON and assert the presence of |
Error categorization | Every error object includes a | An error object is missing the | Validate each error object against a JSON Schema that constrains |
Location precision | Every error and warning includes a JSON Pointer path in a | A | For each entry, resolve the |
Rule reference | Each finding cites the specific OpenAPI Specification section or rule identifier in a | A finding has a missing, generic, or unverifiable | Check that every |
Fix suggestion relevance | Every error includes a | A | Sample 5 errors and manually verify that applying the suggestion resolves the flagged issue without breaking schema validation |
Severity assignment | Each finding has a | A required-field violation is marked as | Run the report against a spec with one known breaking violation and one known style deviation; assert severity values match expectations |
No hallucinated violations | The report only flags issues that are objectively present in the input spec; no fabricated errors about fields or structures that do not exist | The report contains an error referencing a path, schema, or operation that is not present in the source document | Diff the set of reported locations against the set of all nodes in the input spec; assert every reported location exists |
Deterministic output | Running the same prompt with the same input spec and model configuration produces an identical set of errors and warnings across 3 runs | Error counts, categories, or locations vary between runs without changes to the input spec | Execute the prompt 3 times with temperature=0, compare the sorted error lists, and assert exact match on |
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
Use the base prompt with a single spec and lighter validation. Remove the [OUTPUT_SCHEMA] constraint and ask for a plain-text error list instead of structured JSON. Drop severity classification to keep the prompt short.
codeValidate this OpenAPI spec against [VERSION] rules. List every structural error you find with the path or schema location. Do not categorize by severity. Spec: [OPENAPI_SPEC]
Watch for
- Missing
$refresolution checks when refs point to external files - Overly broad instructions that skip
oneOf/anyOfdiscriminator validation - No check for unused or orphaned component schemas

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