Inferensys

Prompt

OpenAPI Spec-Driven Developer Portal Content Prompt Template

A practical prompt playbook for generating getting-started guides, authentication walkthroughs, and use-case narratives from an OpenAPI specification. Includes harness logic to validate that every referenced endpoint, schema, and error code exists in the source spec.
Strategy consultant facilitating AI use case discovery workshop, sticky notes on glass wall, casual corporate meeting.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, ideal user, required context, and when not to use this prompt.

This prompt is designed for DevRel teams and technical writers who need to produce developer portal content that stays synchronized with a live API contract. Instead of writing tutorials that reference fictional endpoints or stale parameter names, the prompt takes a complete OpenAPI specification as ground truth and generates narrative documentation that references only real operations, schemas, and error codes. The core job-to-be-done is bridging the gap between a machine-readable API contract and the human-readable guides that developers rely on during onboarding and integration.

Use this prompt when you need a getting-started guide, an authentication walkthrough, or a use-case tutorial that must pass automated validation against the spec. The prompt works best when you provide a complete, validated OpenAPI 3.0 or 3.1 document along with a clear content objective—such as 'write a Python quickstart for the Orders API' or 'explain how to authenticate and make your first request.' The harness should be configured to parse the spec, extract relevant operations and schemas, and feed them as structured context alongside your content instructions. Every endpoint, parameter, and error code referenced in the output must be traceable back to the source spec, and the validation layer should flag any hallucinated paths or properties before the content reaches a reviewer.

Do not use this prompt for generating the OpenAPI spec itself, for linting spec structure, or for producing API reference pages. Those tasks belong to sibling playbooks in the OpenAPI and API Specification Authoring group, such as the OpenAPI Specification Scaffold from Code Annotations or the OpenAPI Spec to Markdown API Reference templates. This prompt is also not suitable for content that requires subjective design decisions—like choosing between multiple valid API patterns—without a human reviewer in the loop. If your spec is incomplete, contains unresolved $ref targets, or lacks example payloads, fix those issues first using the validation and example-generation playbooks before feeding the spec into this content-generation workflow.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt template delivers reliable developer portal content and where it introduces risk.

01

Good Fit: Complete, Validated OpenAPI Specs

Use when: you have a linted, validated OpenAPI 3.0/3.1 spec with operation IDs, summaries, parameter descriptions, and example payloads. The prompt can trace every endpoint, schema, and error code it references. Guardrail: run Spectral or Redocly linting before feeding the spec into the prompt; reject specs with unresolved $ref targets or missing required fields.

02

Good Fit: Tutorial-Style Content with Real Endpoints

Use when: generating getting-started guides, authentication walkthroughs, or use-case narratives that must reference actual API operations. The prompt produces content where every code sample, cURL command, and endpoint mention is traceable to a spec path. Guardrail: post-process output with a spec-aware validator that flags any referenced operation ID or path not present in the source spec.

03

Bad Fit: Undocumented or Incomplete Specs

Avoid when: the OpenAPI spec is missing authentication schemes, error response schemas, or parameter descriptions. The prompt will hallucinate plausible but incorrect details to fill gaps. Guardrail: preflight the spec for minimum completeness—every endpoint must have at least one success response schema, every security scheme must be defined, and every parameter must have a description.

04

Bad Fit: Specs Without Example Payloads

Avoid when: request bodies and response schemas lack example or examples fields. The prompt will invent sample payloads that may not match actual API behavior. Guardrail: require at least one valid example per schema before using this prompt for tutorial generation; use a separate example-generation prompt to backfill missing examples first.

05

Required Inputs

Must provide: a complete OpenAPI spec (JSON or YAML), the target content type (getting-started, auth walkthrough, use-case narrative), and the specific audience persona (frontend dev, backend dev, integration partner). Optional but recommended: brand voice guidelines, existing portal style samples, and a list of endpoints to emphasize or exclude. Guardrail: strip PII and internal hostnames from the spec before sending to external model providers.

06

Operational Risk: Spec Drift After Publication

Risk: the generated portal content references endpoints, parameters, or schemas that change in a subsequent API release. Published tutorials become incorrect without warning. Guardrail: pair this prompt with a scheduled spec-diff job that flags portal content referencing deprecated or changed operations; trigger content regeneration when breaking changes are detected.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that generates developer portal content from an OpenAPI specification, with placeholders for spec input, content type, audience, and output constraints.

This prompt template generates getting-started guides, authentication walkthroughs, and use-case narratives directly from an OpenAPI specification. It is designed to be inserted into your prompt assembly pipeline, where upstream processes inject the spec, content type, and audience parameters before the model call. Every generated section must reference real endpoints, schemas, and error codes from the provided spec—the harness should reject outputs that invent operations or parameters not present in the source.

text
You are a developer documentation writer generating portal content from an OpenAPI specification.

[SPEC]
The complete OpenAPI specification in JSON or YAML format. All generated content must reference only endpoints, schemas, parameters, and error codes present in this spec.

[CONTENT_TYPE]
One of: getting-started, authentication-walkthrough, use-case-narrative, endpoint-deep-dive, error-handling-guide, or sdk-integration-pattern.

[AUDIENCE]
Target developer persona and experience level, such as "backend engineers familiar with REST APIs" or "frontend developers new to this service."

[USE_CASE]
For use-case-narrative content type only: the specific workflow to document, such as "creating and managing recurring billing subscriptions" or "bulk importing customer records with async validation."

[OUTPUT_SCHEMA]
{
  "title": "string (page title)",
  "introduction": "string (2-3 sentence overview with prerequisite context)",
  "prerequisites": ["string (concrete prerequisite: auth method, SDK version, account tier)"],
  "sections": [
    {
      "heading": "string",
      "content": "string (markdown with inline code references to spec operations)",
      "code_examples": [
        {
          "language": "string",
          "code": "string",
          "description": "string (what this example demonstrates)"
        }
      ],
      "referenced_operations": ["string (operationId from spec)"]
    }
  ],
  "error_reference": [
    {
      "status_code": "integer",
      "error_code": "string",
      "common_cause": "string",
      "resolution": "string"
    }
  ],
  "next_steps": ["string (link or action for further learning)"]
}

[CONSTRAINTS]
- Every referenced_operations entry must match an operationId in [SPEC].
- Every code_example must use endpoints, parameters, and schemas from [SPEC].
- Every error_reference entry must correspond to a documented response in [SPEC].
- Do not invent endpoints, parameters, or error codes.
- Use the exact field names, enum values, and status codes from [SPEC].
- For authentication-walkthrough: include token acquisition, refresh, and scope requirements.
- For getting-started: minimize time-to-first-success with copy-pasteable commands.
- Mark any spec gaps with "[SPEC GAP: description]" rather than fabricating details.

[EXAMPLES]
Input: getting-started content for a payments API spec with API key auth.
Output includes: API key generation steps, first charge endpoint call with curl example, common 401/402 error resolutions, and link to full endpoint reference.

Input: use-case-narrative for "batch invoice generation" from an invoicing API spec.
Output includes: prerequisite customer and product setup, batch creation endpoint walkthrough, polling for async job status, handling partial failures, and webhook event subscription for completion notifications.

[RISK_LEVEL]
Medium. Generated content will be published to a developer portal. Incorrect endpoint references, missing auth steps, or fabricated error codes will break developer trust and increase support load. Require human review before publication.

Adapt this template by replacing each square-bracket placeholder with real values before sending to the model. The [SPEC] placeholder should receive the full OpenAPI document—do not truncate or summarize it, as the model needs complete schema context to generate accurate references. The [OUTPUT_SCHEMA] enforces structured JSON output; pair this with your model's structured output or JSON mode feature to guarantee parseable results. Before publishing generated content, run a post-generation validation step that extracts every referenced_operations value and confirms it exists in the source spec. Flag any [SPEC GAP] markers for manual documentation work. For high-traffic portal pages, consider caching generated content and re-running generation only when the spec changes.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Validate each before sending to the model.

PlaceholderPurposeExampleValidation Notes

[OPENAPI_SPEC]

The complete OpenAPI 3.0 or 3.1 specification as a JSON or YAML string

openapi: 3.1.0 info: title: Petstore paths: /pets: get: ...

Parse as valid JSON/YAML. Must contain top-level 'openapi', 'info', and 'paths' keys. Reject if spec fails OpenAPI structural validation.

[CONTENT_TYPE]

The type of developer portal content to generate

getting-started-guide

Must be one of: getting-started-guide, authentication-walkthrough, use-case-narrative, endpoint-tutorial, integration-guide. Reject unknown values.

[TARGET_AUDIENCE]

The developer persona and experience level for tone and depth

backend-engineer-intermediate

Must be one of: frontend-beginner, backend-intermediate, fullstack-advanced, mobile-developer, integration-engineer. Controls code language preference and explanation depth.

[PRIMARY_ENDPOINT_PATH]

The main API path the content should focus on

/pets

Must exist in [OPENAPI_SPEC].paths. Reject if path not found. Use as narrative anchor for tutorials and walkthroughs.

[AUTH_SCHEME_NAME]

The security scheme name from the spec to document in auth walkthroughs

OAuth2

Must exist in [OPENAPI_SPEC].components.securitySchemes. Required when [CONTENT_TYPE] is authentication-walkthrough. Null allowed for other content types.

[INCLUDE_CODE_SAMPLES]

Whether to generate code snippets in the output

Must be boolean true or false. When true, prompt includes language-specific example generation instructions. When false, output is prose-only.

[TARGET_LANGUAGES]

Programming languages for code samples when [INCLUDE_CODE_SAMPLES] is true

["python", "javascript", "curl"]

Must be a JSON array of supported language identifiers. Each value must be in allowed set: python, javascript, typescript, java, go, ruby, php, curl, csharp. Reject unknown languages.

[OUTPUT_FORMAT]

The desired output format for the generated content

markdown

Must be one of: markdown, json-structured. When json-structured, output must conform to a predefined schema with sections, code_blocks, and endpoint_references arrays.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the OpenAPI Spec-Driven Developer Portal Content prompt into a production documentation pipeline with pre-validation, post-validation, and retry logic.

The harness for this prompt is responsible for ensuring that every piece of generated developer portal content references real endpoints, schemas, and error codes that actually exist in the source OpenAPI specification. Before the prompt ever runs, the harness must parse the spec, extract a machine-readable index of all operation IDs, path patterns, parameter names, schema references, and documented HTTP status codes. This index becomes the ground truth that post-generation validation checks against. Without this harness, the prompt will confidently generate tutorials that reference non-existent endpoints or hallucinated error codes, which erodes developer trust faster than missing documentation.

Pre-validation begins with spec integrity checks. The harness must confirm the OpenAPI spec parses successfully, that all $ref pointers resolve, and that every operation has a unique operationId. If the spec fails these checks, the harness should abort and return a structured error rather than feeding a broken spec to the prompt. Once the spec passes, the harness extracts a lookup table mapping each operationId to its HTTP method, path, available parameters, request body schema reference, and documented response status codes. This table is passed into the prompt as part of the [CONTEXT] placeholder alongside the full spec text. The harness should also inject a [CONSTRAINTS] block that explicitly instructs the model to only reference operations, parameters, and error codes present in the provided spec index, and to mark any referenced endpoint with its exact operationId.

Post-generation validation is where the harness earns its keep. The generated content must be scanned for any API reference—endpoint paths, HTTP methods, parameter names, schema property names, or status codes—and each reference must be checked against the pre-extracted spec index. Any reference that cannot be matched to a real spec element must be flagged. The harness should produce a validation report with three categories: matched references (confirmed in spec), unmatched references (likely hallucinations), and missing coverage (spec operations that exist but were never mentioned in the generated content). A content piece that contains unmatched references should trigger a retry with the validation errors injected into the prompt as additional [CONSTRAINTS], instructing the model to correct or remove the hallucinated references.

Retry logic must be bounded. The harness should attempt a maximum of three regeneration cycles per content piece. On each retry, the validation errors from the previous attempt are appended to the prompt as explicit correction instructions. If after three attempts the content still contains unmatched references, the harness should surface the content with a review-required flag and a detailed error manifest for human triage. This prevents infinite retry loops while ensuring that no hallucinated API surface reaches the developer portal without review. The harness should also log every validation failure with the specific unmatched string, the prompt version, the model used, and the retry count for observability.

Model choice matters for this workflow. The prompt requires strong instruction-following and the ability to cross-reference structured spec data with narrative prose. Models with larger context windows are preferred because full OpenAPI specs can exceed 10,000 tokens before any generated content. If the spec is too large for a single context window, the harness should implement a chunking strategy: split the spec by tag groups or path prefixes, generate portal content per section, and then run a cross-section consistency check to ensure the same endpoint is not documented with conflicting instructions across sections. For high-stakes public documentation, always route the final validated output through a human review queue before publication, regardless of automated validation scores.

Wire this harness into your CI/CD pipeline so that every spec change triggers a re-generation and re-validation of affected portal content. Store the spec version hash alongside each generated content piece to enable diff-based updates rather than full regeneration. When the spec changes, the harness should identify which operations were added, modified, or removed, and only regenerate the tutorial sections that reference those operations. This keeps your developer portal in sync with your API contract without burning compute on unchanged content.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the developer portal content generated from an OpenAPI spec. Use this contract to build automated acceptance checks before publishing.

Field or ElementType or FormatRequiredValidation Rule

guide_title

string

Must be non-empty and contain at least one endpoint-related keyword from the source spec

intended_audience

enum: beginner, intermediate, advanced

Must match one of the allowed enum values; null not permitted

prerequisites_section

array of strings

Each prerequisite must reference a concrete setup step (e.g., API key, SDK install); array must contain at least 1 item

referenced_endpoints

array of operationId strings

Every operationId must exist in the source OpenAPI spec; array must contain at least 1 item; duplicate entries must be flagged

code_examples

array of objects with language, code, description

Each code example must include a non-empty language field and a code block that compiles or parses without syntax errors; description must be non-empty

authentication_instructions

string

Must reference the security scheme name from the source spec; if spec has no security schemes, field must contain explicit 'No authentication required' statement

error_handling_section

array of objects with status_code, error_body, resolution

If present, every status_code must match an HTTP status code defined in the source spec's responses; resolution must be non-empty

schema_reference_count

integer

Must be greater than 0; count of unique schema names referenced in the guide must match the number of distinct $ref targets found in the guide text

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when generating developer portal content from an OpenAPI spec, and how to guard against it.

01

Hallucinated Endpoints and Parameters

What to watch: The model invents plausible-sounding endpoints, query parameters, or response fields that don't exist in the source spec. This is the most dangerous failure mode because it produces documentation that looks correct but sends developers to broken URLs or non-existent functionality. Guardrail: Require the harness to extract every referenced operationId, path, parameter name, and schema property from the generated content, then validate each one against the spec. Flag any reference not found in the spec as a hallucination and block publication until resolved.

02

Stale or Incomplete Auth Documentation

What to watch: The generated getting-started guide or auth walkthrough omits required scopes, uses an outdated token endpoint, or describes a flow that doesn't match the security scheme objects in the spec. Developers following the guide hit 401 errors and abandon integration. Guardrail: Cross-reference every security requirement mentioned in the generated content against the spec's security schemes and per-operation security requirements. Add a validation step that checks scope-to-endpoint mappings and flags any endpoint documented without its required scope.

03

Example Payload Drift from Schema

What to watch: The model generates example request bodies or response payloads that violate the schema—wrong types, missing required fields, or enum values that don't match. These examples become copy-paste traps for developers. Guardrail: Run every generated example payload through a schema conformance checker before publication. Flag type mismatches, missing required properties, and invalid enum values. If the spec includes examples, prefer those over model-generated ones and only generate new examples when the spec lacks them.

04

Error Code and Troubleshooting Fabrication

What to watch: The model generates plausible error scenarios and troubleshooting steps that don't correspond to actual error responses defined in the spec. Developers waste time debugging errors that never occur or miss real failure modes entirely. Guardrail: Constrain error documentation generation to only reference HTTP status codes and error response schemas explicitly defined in the spec. For each error code mentioned, verify it appears in at least one operation's responses object. If the spec lacks error documentation, flag the gap rather than inventing content.

05

Deprecated Surface Still Featured Prominently

What to watch: The generated tutorial or use-case narrative centers on a deprecated endpoint or parameter, steering new developers toward functionality scheduled for removal. The deprecation metadata exists in the spec but the model ignores it. Guardrail: Before generating any content, extract all deprecated operations and schemas from the spec. Add a constraint that deprecated surfaces must not appear in getting-started guides or primary tutorials. If a deprecated endpoint must be mentioned, require a deprecation warning and link to the replacement.

06

Inconsistent Terminology Across Generated Pages

What to watch: When generating multiple pages (quickstart, auth guide, use-case narrative) from the same spec, the model uses different terms for the same concept—"API key" vs

IMPLEMENTATION TABLE

Evaluation Rubric

Score each criterion on a pass/fail or 1-5 scale. Aggregate scores determine whether content proceeds to publication or requires human review.

CriterionPass StandardFailure SignalTest Method

Endpoint Reference Accuracy

Every referenced endpoint path and HTTP method exists in the source OpenAPI spec

Tutorial mentions an endpoint not present in the spec or uses wrong HTTP method

Parse generated content for all endpoint references; cross-check against spec paths and methods using a scripted validator

Schema Field Fidelity

All referenced request/response fields match the spec's schema property names, types, and required status

Generated content uses a field name not in the schema, misstates a type, or marks an optional field as required

Extract all field references from the tutorial; validate against JSON Schema from the spec's component schemas

Authentication Flow Correctness

Described auth method, grant type, scopes, and header format match the spec's security schemes and security requirements

Tutorial instructs user to use Basic auth when spec requires Bearer token, or omits required OAuth scope

Compare tutorial auth instructions against the spec's securityDefinitions/securitySchemes and per-operation security arrays

Error Code Coverage

All error codes mentioned in the tutorial exist in the spec's responses for the referenced endpoints

Tutorial describes a 404 error for an endpoint that only documents 400 and 500 responses

Map every error code in the tutorial to a response key in the spec's operation object; flag unmatched codes

Code Example Validity

Every code snippet uses correct method, path, headers, and a request body that conforms to the spec's schema

Code example sends a POST with a JSON body that fails schema validation or uses wrong Content-Type

Extract code blocks; validate request shape against the spec's requestBody schema using a JSON Schema validator

Use-Case Narrative Coherence

The tutorial's scenario logically connects the endpoints in the order they would be called in a real integration

Tutorial describes a workflow that calls GET /users/{id} before POST /users to create the user

Manual review or LLM judge evaluates whether the sequence of operations matches a realistic integration pattern

Placeholder and Variable Consistency

All placeholders like {userId} or {apiKey} are consistently named and match the spec's parameter definitions

Tutorial uses {user_id} in one place and {userId} in another for the same parameter

Regex-extract all placeholders; check for naming consistency and match against spec parameter names

Deprecation Awareness

Tutorial does not feature deprecated endpoints, parameters, or schemas unless explicitly documenting migration

Generated guide uses a deprecated endpoint without noting its sunset date or replacement

Cross-reference all referenced operations and schemas against spec deprecation fields; flag any deprecated surface used without migration context

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single endpoint or small spec subset. Replace [FULL_OPENAPI_SPEC] with a minimal spec containing 2-3 operations. Relax the output schema to accept a single tutorial section instead of the full [OUTPUT_SCHEMA]. Skip the spec-reference validation step and review output manually.

Watch for

  • Generated content referencing endpoints not in the spec
  • Tutorial steps that skip authentication setup
  • Code samples that don't match the spec's actual request schemas
  • Missing error code references in troubleshooting sections
Prasad Kumkar

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.