openapi-spec-generation

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

Updated Aug 25, 2026
One-click install
npx skills add https://github.com/AliJ021/labelmod-core --skill openapi-spec-generation-alij021
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openapi-spec-generation
Source: https://github.com/AliJ021/labelmod-core/tree/main/.claude/skills/openapi-spec-generation
Command: npx skills add https://github.com/AliJ021/labelmod-core --skill openapi-spec-generation-alij021

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, especially when keeping specs in sync with evolving API implementations across frameworks like FastAPI and Express. ## Core Features & Use Cases - Design-First Spec Authoring: Complete OpenAPI 3.1 YAML templates with reusable components, security schemes, pagination schemas, and standardized error responses. - Code-First Generation: Patterns for generating specs from Python/FastAPI with Pydantic models and from TypeScript using tsoa decorators. - Validation and SDK Generation: Spectral and Redocly linting configurations plus openapi-generator-cli commands for TypeScript, Python, and Go client SDKs. - Use Case: You are building a REST API in FastAPI and need a published contract. Use this Skill to generate the OpenAPI spec from your Pydantic models, lint it with Spectral, and produce a TypeScript client SDK for your frontend team. ## Quick Start Ask the AI to generate an OpenAPI 3.1 specification for your REST API endpoints, including schemas, error responses, and security definitions.

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 automatically generates an OpenAPI spec from your Pydantic models and route decorators. Define models with Field validation, set response_model and status_code on endpoints, then export the spec as JSON by calling app.openapi().

How to create an OpenAPI 3.1 specification from scratch?

Start with the design-first template defining info, servers, paths, and components sections. Reuse schemas, parameters, and responses through $ref references, and define securitySchemes like bearerAuth or apiKey under components.

What is the difference between design-first and code-first OpenAPI?

Design-first means writing the spec before implementing code, which suits new APIs and contract agreements. Code-first generates the spec from annotated code, which fits existing APIs built with frameworks like FastAPI or tsoa.

How do I validate an OpenAPI spec with Spectral?

Install @stoplight/spectral-cli and create a .spectral.yaml ruleset extending spectral:oas. Add rules for operationId presence, descriptions, and naming conventions, then run spectral lint on your spec file.

Can I generate client SDKs from an OpenAPI spec?

Yes, use openapi-generator-cli with your spec file to generate clients for TypeScript (typescript-fetch), Python, or Go. Pass generator-specific options through the additional-properties flag such as package names.

When should I not use code-first OpenAPI generation?

Avoid code-first when multiple teams must agree on a contract before implementation begins, or when the API consumers are external partners. In those cases, design-first specs provide a stable agreement independent of implementation details.