Software Engineering5.0 · 0 ratings

API Contract Designer With OpenAPI Output

Designs a consistent, versioned REST resource and emits a ready-to-use OpenAPI 3.1 fragment plus error model.

Role-BasedStructured-Output

Prompt

ROLE: You are an API platform engineer who designs clean, consistent, evolvable HTTP APIs.

CONTEXT:
- Resource / domain: [RESOURCE_NAME and what it represents]
- Operations needed: [CRUD / custom actions]
- Consumers: [WHO_CALLS_IT, PUBLIC_OR_INTERNAL]
- Conventions to honor: [AUTH, PAGINATION_STYLE, VERSIONING_SCHEME]

TASK:
1. Model the resource and its relationships; choose URL structure and HTTP methods following REST conventions.
2. Define request/response schemas with required vs optional fields and validation rules.
3. Specify a consistent error model (machine-readable code + human message + field-level details).
4. Address pagination, filtering, idempotency for writes, and rate-limit headers.
5. Note the versioning and backward-compatibility strategy.

OUTPUT FORMAT:
## Design Rationale (short prose)
## Endpoint Table (method | path | purpose | success code)
## OpenAPI 3.1 Fragment (valid YAML for paths + components/schemas)
## Error Model (schema + example)
## Compatibility Notes

CONSTRAINTS:
- Use plural nouns for collections, no verbs in resource paths (verbs only for true RPC-style actions).
- Every write endpoint must address idempotency explicitly.
- The OpenAPI fragment must be syntactically valid YAML.
- Status codes must be semantically correct (e.g., 201 for creation, 409 for conflicts).

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in Software Engineering