Inferensys

Prompt

OpenAPI Deprecation Field Annotation Prompt Template

A practical prompt playbook for using OpenAPI Deprecation Field Annotation Prompt Template in production AI workflows.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for annotating deprecation metadata in OpenAPI specifications.

This prompt is designed for API governance teams, platform engineers, and technical product managers who need to systematically add deprecation metadata to existing OpenAPI specifications. The core job-to-be-done is transforming a spec that has unannotated deprecated endpoints into one where every deprecated path, operation, or schema property carries a complete set of machine-readable and human-readable deprecation fields. This includes deprecated: true, x-sunset dates, migration guide URLs, and replacement operation IDs. The reader is expected to have an existing OpenAPI 3.0 or 3.1 specification and a deprecation policy that defines sunset timelines, replacement endpoints, and communication standards.

Use this prompt when you have a batch of operations or schemas that need consistent deprecation annotation and you want to enforce a uniform structure across your API surface. It is particularly valuable during API version cleanup sprints, pre-release governance reviews, or when onboarding legacy APIs into a centralized developer portal. The prompt expects structured inputs: the target spec fragment, a deprecation policy document, and a mapping of deprecated surfaces to their replacements. Do not use this prompt for greenfield API design, for generating net-new deprecation policies from scratch, or for deciding whether an endpoint should be deprecated—it assumes the deprecation decision has already been made and only needs to be documented correctly.

Before running this prompt, ensure you have a validated OpenAPI spec, a clear sunset calendar, and a documented replacement for every surface being deprecated. The harness described in the implementation section will reject annotations that lack a replacement reference or a sunset date, so incomplete inputs will produce validation errors rather than partial output. If your team has not yet identified replacements for deprecated endpoints, start with an API inventory audit before applying this prompt. The output is a spec patch or a fully annotated spec fragment ready for review, not a final publication artifact—always run the conformance checks and human review steps before merging into your published spec.

PRACTICAL GUARDRAILS

Use Case Fit

Where the OpenAPI Deprecation Field Annotation prompt works and where it introduces risk. Use these cards to decide if this prompt fits your current API governance workflow.

01

Good Fit: Spec-First Governance

Use when: your team maintains a canonical OpenAPI spec as the source of truth and needs to systematically mark deprecated endpoints, parameters, or schemas. Guardrail: the prompt assumes the spec is already valid; run OpenAPI validation before annotation to avoid propagating structural errors.

02

Good Fit: Sunset Calendar Enforcement

Use when: you need every deprecated surface to carry a sunset date, a migration link, and a replacement operationId. Guardrail: the harness must reject any deprecated path that lacks a documented alternative; never ship a deprecation annotation without a verified migration target.

03

Bad Fit: Runtime Deprecation Detection

Avoid when: you need to detect deprecated usage from live traffic or API gateways. This prompt annotates specs, not runtime telemetry. Guardrail: pair this prompt with gateway-level deprecation headers and monitoring; the spec annotation is the contract, not the enforcement mechanism.

04

Bad Fit: Code-Only Workflows Without a Spec

Avoid when: your API surface is defined only in framework code with no OpenAPI spec. The prompt requires an existing spec to annotate. Guardrail: generate or extract a spec first using a scaffold prompt, then apply deprecation annotations as a separate governed step.

05

Required Input: Complete Operation and Schema Inventory

Risk: the model may miss deprecated surfaces that are not explicitly referenced in the provided spec fragment. Guardrail: always supply the full path, operation, and schema context for the surface being deprecated; the harness should verify that every deprecated: true field has a corresponding x-sunset and x-migration extension.

06

Operational Risk: Stale Migration Links

Risk: migration URLs and replacement operation IDs can become invalid after subsequent spec changes. Guardrail: implement a periodic link checker in CI that validates every x-migration URL and operationId reference; flag any broken migration path before the spec is published to a developer portal.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for annotating OpenAPI specifications with deprecation metadata, including sunset dates, migration links, and replacement operation IDs.

This prompt template is designed to be integrated into an API governance pipeline. It takes an existing OpenAPI specification and a set of deprecation rules as input, and it produces an annotated specification where every deprecated surface—paths, operations, and schemas—is clearly marked with structured metadata. The template uses square-bracket placeholders for all dynamic inputs, making it straightforward to adapt for different API surfaces and organizational policies.

text
You are an API governance assistant. Your task is to annotate an OpenAPI specification with deprecation metadata.

## INPUT
- OpenAPI Specification: [OPENAPI_SPEC]
- Deprecation Policy: [DEPRECATION_POLICY]
- Current Date: [CURRENT_DATE]

## CONSTRAINTS
- Do not modify any existing schema, path, or operation logic.
- Only add or update the `deprecated` field and `x-sunset` extension properties.
- Every deprecated operation or schema MUST have a documented alternative.
- If no alternative exists, flag the item for human review instead of marking it deprecated.
- Use the exact sunset date format: YYYY-MM-DD.
- Migration links must be absolute URLs or valid internal operationId references.

## OUTPUT_SCHEMA
Return a JSON object with two keys:
1. `annotated_spec`: The complete OpenAPI specification with deprecation annotations applied.
2. `review_required`: An array of objects for items that require human review, each with:
   - `location`: The JSON path to the item (e.g., "paths./users.get")
   - `reason`: Why it could not be automatically deprecated
   - `recommendation`: Suggested next steps

## DEPRECATION ANNOTATION RULES
For each path, operation, or schema property that matches the deprecation policy:
1. Set `deprecated: true`.
2. Add an `x-sunset` object with:
   - `sunset-date`: [SUNSET_DATE] or a calculated date based on the policy
   - `replacement`: The operationId or URL of the replacement
   - `migration-guide`: A link to the migration documentation
   - `deprecation-notice`: A human-readable explanation
3. If the item is a schema property, also add `x-sunset` to the parent schema's description if not already present.

## EXAMPLES
[EXAMPLES]

## RISK_LEVEL
[RISK_LEVEL]

To adapt this template, replace the placeholders with concrete values for your workflow. [OPENAPI_SPEC] should be the raw YAML or JSON of your specification. [DEPRECATION_POLICY] defines the rules for what gets deprecated—this could be a list of operation IDs, a date threshold, or a reference to an external policy document. [EXAMPLES] should include one or two few-shot examples showing a path or schema before and after annotation. For high-stakes APIs, set [RISK_LEVEL] to high and ensure the output is routed through a human review queue before the annotated spec is published. The review_required array in the output schema is your safety net: it captures items the model could not confidently annotate, preventing silent failures in production.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the OpenAPI Deprecation Field Annotation prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check the input before execution.

PlaceholderPurposeExampleValidation Notes

[OPENAPI_SPEC]

The source OpenAPI 3.0 or 3.1 specification document as a raw JSON or YAML string

openapi: 3.1.0 info: title: Payments API paths: /v1/charges: get: operationId: listCharges

Parse check: must be valid JSON or YAML. Schema check: must conform to OpenAPI 3.0 or 3.1 structure. Reject if spec version is missing or paths block is empty.

[DEPRECATION_POLICY]

Organizational rules defining required deprecation metadata fields, sunset timelines, and communication standards

All deprecated operations must include x-sunset-date, x-deprecation-migration-link, and x-deprecated-at. Sunset dates must be at least 90 days from deprecation announcement.

Schema check: must include required field names and minimum timeline rules. Parse check: confirm policy is a non-empty string with actionable rules. Reject if policy contains only vague guidance like 'follow best practices'.

[REPLACEMENT_MAP]

A mapping of deprecated operationIds to their replacement operationIds or resource paths

{"listCharges": "listTransactions", "createCharge": "createPaymentIntent"}

Schema check: must be a valid JSON object with string keys and string values. Null check: null allowed if no replacements exist, but every deprecated operation without a replacement will trigger a warning in the harness. Validate that every key exists as an operationId in [OPENAPI_SPEC].

[SUNSET_DATE_FORMAT]

The expected date format for x-sunset-date values, typically RFC 3339 or ISO 8601

2026-06-30T00:00:00Z

Format check: must be a valid date format string recognizable by standard date parsers. Default to RFC 3339 if not specified. Reject ambiguous formats like 'MM/DD/YYYY' without timezone.

[MIGRATION_BASE_URL]

The base URL prefix for constructing migration guide links when no explicit link is provided in [REPLACEMENT_MAP]

Format check: must be a valid URL string starting with https://. Null allowed if all replacements have explicit links. Trailing slash normalization required before link construction.

[OUTPUT_FORMAT]

The desired output format: annotated OpenAPI spec, change summary, or both

both

Enum check: must be one of 'spec', 'summary', or 'both'. Default to 'both' if not specified. Reject unrecognized values.

[STRICT_MODE]

Whether to require that every deprecated surface has a documented replacement or migration link

Boolean check: must be 'true' or 'false'. When true, the harness must fail validation if any deprecated operation, parameter, or schema property lacks a replacement reference or migration link.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the deprecation annotation prompt into an API governance pipeline with validation, retries, and human review gates.

This prompt is designed to be called programmatically as part of a spec governance workflow, not as a one-off chat interaction. The typical integration point is a CI/CD pipeline or an internal API governance service that processes OpenAPI specs before they are published to a developer portal or gateway. The harness should extract the target spec, identify operations and schemas that already carry a deprecated: true flag, and pass each deprecated surface to the prompt along with the full spec context so the model can locate replacement operations and suggest accurate migration links. Because the prompt modifies a machine-readable specification that downstream tools consume, every output must pass structural validation before it is merged back into the spec.

The implementation should follow a validate-before-merge pattern. After the model returns annotated paths, operations, or schemas, run the output through an OpenAPI structural validator (such as Redocly CLI, Spectral, or a custom JSON Schema validator) to confirm that no required fields were dropped and that all $ref targets remain intact. Next, apply a deprecation-specific linting rule: every surface marked deprecated: true must have a non-empty x-sunset-date (or equivalent extension), a x-migration-guide URL, and either a x-replacement-operationId or a documented reason why no replacement exists. If the model output fails these checks, retry once with the validation errors injected into the prompt as additional [CONSTRAINTS]. If the retry also fails, route the spec to a human reviewer through a pull request comment or a governance dashboard ticket. Do not silently merge incomplete deprecation annotations—downstream consumers rely on this metadata to plan their migrations.

For model selection, prefer a model with strong structured output support and a large context window, since the prompt requires the full spec as input. GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable choices. Enable structured output mode (JSON mode or function calling with a strict schema) to enforce the expected annotation format. Log every invocation with the spec version, the list of deprecated surfaces passed in, the model's raw output, validation results, and whether the output was auto-merged or escalated. This audit trail is essential for governance reviews and for debugging cases where the model hallucinates replacement operation IDs or invents sunset dates. Finally, version the prompt template itself in your prompt registry and pin model versions in production to avoid silent behavior changes when providers update their models.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the deprecation annotation output. Use this contract to validate the model response before merging annotations into the target OpenAPI spec.

Field or ElementType or FormatRequiredValidation Rule

deprecated

boolean

Must be true on every annotated path, operation, or schema property. Reject if false or absent on a target surface.

x-sunset-date

string (date)

Must match ISO 8601 date format (YYYY-MM-DD). Reject if date is in the past or unparseable.

x-migration-link

string (URL)

Must be a valid absolute URL. Reject if relative, empty, or returning a 4xx status on HEAD check.

x-replacement-operation-id

string

If present, must match an existing operationId elsewhere in the spec. Null allowed when no direct replacement exists.

x-deprecation-notice

string

If present, must be non-empty and under 500 characters. Null allowed. Reject if present but empty string.

description (updated)

string

Must contain a deprecation warning sentence referencing the sunset date and migration link. Reject if original description is overwritten without preserving prior content.

x-deprecated-alternative

string (operationId or path)

If present, must reference a valid operationId or path in the spec. Reject if dangling reference. Null allowed.

affected_operation_id

string

Must match the operationId of the deprecated endpoint in the source spec. Reject if missing or referencing a non-existent operation.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when annotating deprecation fields in OpenAPI specs and how to prevent it.

01

Missing Replacement Operation ID

What to watch: The model annotates a deprecated operation but omits the x-sunset-replacement extension or leaves the replacement operationId null. Downstream consumers see a sunset date with no migration path. Guardrail: Add a post-generation validation rule that rejects any deprecated operation where deprecated: true is present but x-sunset-replacement is absent or empty.

02

Sunset Date in the Past

What to watch: The model generates a x-sunset-date that has already passed or is unreasonably soon (e.g., yesterday). This signals hallucination or a failure to ground the date in the provided timeline context. Guardrail: Validate that every x-sunset-date is a future ISO 8601 date. If the date is within 30 days, flag for human review to confirm the aggressive timeline is intentional.

03

Deprecation Annotation on Non-Existent Paths

What to watch: The model hallucinates a deprecation annotation for an endpoint that does not exist in the source spec. This creates orphaned metadata that confuses linters and downstream tooling. Guardrail: Cross-reference every annotated path + method combination against the original spec. Remove any deprecation block that does not match an existing operation.

04

Inconsistent Deprecation Across Operation Variants

What to watch: The model deprecates GET /users/{id} but leaves PATCH /users/{id} unmarked, or deprecates a path but not its sub-resources. Consumers receive mixed signals about what is safe to use. Guardrail: After generation, group operations by resource path. If one operation on a path is deprecated, flag all sibling operations for human review to confirm whether they should also be deprecated.

05

Deprecation Link Rot

What to watch: The model generates a plausible-looking but non-functional migration URL in the x-sunset-link or externalDocs.url field. Developers click through to a 404 page. Guardrail: If the prompt includes a base URL for documentation, validate that generated links start with that prefix. For external links, add a note in the output requiring manual link verification before publication.

06

Over-Deprecation of Stable Endpoints

What to watch: The model applies deprecated: true to endpoints that are not on the deprecation list, especially when the input context is ambiguous about which operations are being sunset. Guardrail: Require an explicit deprecation target list as a prompt input. After generation, diff the annotated spec against the original and flag any newly deprecated operation that was not in the input target list for human approval.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality of an OpenAPI spec annotated with deprecation fields. Use this rubric to test the prompt's output before integrating it into an API governance pipeline.

CriterionPass StandardFailure SignalTest Method

Deprecation Field Presence

Every deprecated path, operation, or schema property includes the deprecated: true field.

A deprecated surface is missing the deprecated field or it is set to false.

Parse the output spec and assert deprecated exists for all items listed in the [DEPRECATION_LIST] input.

Sunset Date Annotation

Every deprecated item includes a valid x-sunset-date extension formatted as an RFC 3339 date-time.

The x-sunset-date field is missing, empty, or uses an incorrect date format.

Validate the x-sunset-date value against the RFC 3339 regex pattern for all deprecated items.

Migration Link Validity

Every deprecated operation includes an x-migration-link or x-replacement-operation-id pointing to a valid alternative.

The migration link is a broken URL, or the replacement operation ID does not exist in the spec.

Resolve the x-migration-link URL and check for a 200 status; verify the x-replacement-operation-id matches an existing operationId.

Replacement Operation ID Accuracy

The x-replacement-operation-id references an operation that is not itself deprecated.

The replacement operation ID points to another deprecated endpoint, creating a circular or dead-end migration path.

Check the deprecated status of the target operation ID; assert it is false or undefined.

Description Clarity

The description field for every deprecated item clearly states the deprecation, the reason, and the recommended action.

The description is a generic placeholder like 'deprecated' or is missing entirely.

Perform a keyword check for the presence of 'deprecated', a reason, and a reference to the replacement in the description string.

Non-Deprecated Surface Integrity

No active (non-deprecated) path, operation, or schema property is incorrectly annotated as deprecated.

A currently supported endpoint or field is falsely marked as deprecated: true.

Diff the output spec against the [INPUT_SPEC] and flag any newly deprecated items not present in the [DEPRECATION_LIST].

Schema Completeness

The output is a syntactically valid OpenAPI specification with all original content preserved.

The output fails OpenAPI schema validation or is missing original paths, schemas, or security definitions.

Run the output through an OpenAPI 3.0/3.1 schema validator and assert zero structural errors.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single OpenAPI file. Remove strict output schema requirements initially—just ask for a markdown table of deprecated surfaces with sunset dates and migration links. Use a frontier model with a large context window to avoid chunking complexity.

code
Analyze [OPENAPI_SPEC] and list every deprecated path, operation, and schema.
For each, extract: deprecation date, sunset date, migration link, replacement operationId.
Output as a markdown table.

Watch for

  • Missing deprecated: true on nested schemas referenced by deprecated operations
  • Sunset dates parsed incorrectly from free-text descriptions
  • Replacement operationIds that don't exist in the spec
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.