Use to generate an OpenAPI 3.x YAML specification for an API, either from existing code or from a description. Activate for creating API documentation, generating client SDKs, or defining an API contract. Do NOT use for GraphQL schema generation, API implementation, or Postman collection creation.
Generate complete OpenAPI 3.x YAML specifications from code or descriptions for SDK generation, documentation, and contract enforcement.
| Variable | Type | Req | Description |
|---|---|---|---|
tech_stack | string | Yes | e.g., "Node.js + Express" |
api_description | string | Yes | Endpoints, request/response shapes, auth, errors |
context | string | Yes | Version, base URL, audience, schema reuse |
| Case | Strategy |
|---|---|
| No existing docs | Infer behavior from code; flag inferred endpoints for review. |
| Polymorphism | Use oneOf/anyOf with discriminator fields. |
| File uploads | Use multipart/form-data with format: binary. |
flowchart TD
A([Start: OpenAPI Spec Generation]) --> B{Source of API description?}
B -- Existing code --> C[Infer endpoints from routes/controllers, note inferred parts]
B -- Written description --> D[Parse endpoints, methods, request/response shapes]
C & D --> E[Define info: title, version, description, contact, license]
E --> F[Define server URLs: dev / staging / prod]
F --> G{Auth method?}
G -- Bearer JWT --> H[Define BearerAuth security scheme]
G -- API Key --> I[Define ApiKey security scheme]
G -- OAuth2 --> J[Define OAuth2 flows]
G -- Basic --> K[Define BasicAuth scheme]
H & I & J & K --> L[Apply security globally or per-operation]
L --> M[Define paths: for each endpoint add method, summary, tags]
M --> N{Request has body?}
N -- Yes --> O[Define requestBody schema with examples]
N -- No --> P
O --> P[Define parameters: path, query, header with types + validation]
P --> Q[Define responses: 200/201 success + 400/401/403/404/422/500 errors]
Q --> R{Polymorphic response?}
R -- Yes --> S[Use oneOf / anyOf with discriminator]
R -- No --> T
S & T --> U{File upload endpoint?}
U -- Yes --> V[Use multipart/form-data + format: binary]
U -- No --> W
V & W --> X[Extract reusable schemas to components/schemas]
X --> Y[Add realistic examples for request + response + errors]
Y --> Z[Validate with Swagger Editor / Spectral linter]
Z --> AA([Output: Complete OpenAPI 3.x YAML spec])
@upstash/context7-mcp: Library documentation and examples.| Version | Date | Description |
|---|---|---|
| 1.1.0 | 2026-03-20 | Restructured: moved examples to examples/, references to references/, added compatibility and license fields |
| 1.0.0 | 2026-03-20 | Initial release |