openapi-spec-generation

Generate and validate OpenAPI 3.1 specifications from design-first templates or code-first frameworks.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill openapi-spec-generation-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openapi-spec-generation
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/openapi-spec-generation
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill openapi-spec-generation-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing and maintaining accurate OpenAPI specifications by hand is error-prone and time-consuming, and teams struggle to keep API contracts, documentation, and generated SDKs in sync with actual implementations. ## Core Features & Use Cases - Design-First Spec Authoring: Provides a complete OpenAPI 3.1 template covering paths, reusable schemas, parameters, responses, examples, and security schemes (Bearer JWT, API key). - Code-First Generation: Patterns for FastAPI (Pydantic models with Field validation) and TypeScript/tsoa (decorator-based controllers) that emit specs directly from code. - Validation & SDK Generation: Spectral and Redocly linting configurations plus openapi-generator-cli commands for TypeScript, Python, and Go clients. - Use Case: A backend team building a user management API can scaffold a full OpenAPI 3.1 spec with pagination, error responses, and rate-limit headers, then lint it with Spectral and generate a TypeScript client SDK in one workflow. ## Quick Start Generate an OpenAPI 3.1 specification for my REST API with CRUD endpoints, JWT bearer authentication, and paginated list responses.

Frequently Asked Questions about openapi-spec-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an OpenAPI spec from FastAPI code?

FastAPI generates OpenAPI automatically from Pydantic models and route decorators. Define models with Field validation, set response_model and status_code on endpoints, then export the spec as JSON via app.openapi().

How to generate OpenAPI from TypeScript with tsoa?

tsoa generates OpenAPI specs from TypeScript decorators like @Route, @Get, @Security, and @Response on controller classes. Interfaces and enums in your code become component schemas in the generated specification.

What is the difference between design-first and code-first API development?

Design-first writes the OpenAPI spec before any code, suiting new APIs and contract-driven teams. Code-first generates the spec from annotated code, fitting existing APIs, while hybrid approaches annotate code to keep both in sync.

How do I validate an OpenAPI spec with Spectral or Redocly?

Run spectral lint with a .spectral.yaml ruleset extending spectral:oas to enforce operationIds, descriptions, and naming conventions. Redocly offers redocly lint with rules like no-invalid-media-type-examples and MIME type enforcement.

Can I generate client SDKs from an OpenAPI specification?

Yes, openapi-generator-cli generates clients from a spec for TypeScript (typescript-fetch), Python, and Go. Pass the spec file with -i, choose a generator with -g, and set output options via additional-properties.

When should I not use code-first OpenAPI generation?

Avoid code-first when multiple teams must agree on a contract before implementation, since the spec becomes an artifact of code rather than an agreed design. Design-first is better for new APIs requiring upfront consumer alignment.