Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Generate OpenAPI 3.x specifications from existing code, routes, or descriptions with proper schemas and documentation.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: openapi-spec-generation3description: Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.4---56# OpenAPI Spec Generation78Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs.910## When to Use This Skill1112- Creating API documentation from scratch13- Generating OpenAPI specs from existing code14- Designing API contracts (design-first approach)15- Validating API implementations against specs16- Generating client SDKs from specs17- Setting up API documentation portals1819## Core Concepts2021### 1. OpenAPI 3.1 Structure2223```yaml24openapi: 3.1.025info:26title: API Title27version: 1.0.028servers:29- url: https://api.example.com/v130paths:31/resources:32get: ...33components:34schemas: ...35securitySchemes: ...36```3738### 2. Design Approaches3940| Approach | Description | Best For |41| ---------------- | ---------------------------- | ------------------- |42| **Design-First** | Write spec before code | New APIs, contracts |43| **Code-First** | Generate spec from code | Existing APIs |44| **Hybrid** | Annotate code, generate spec | Evolving APIs |4546## Templates and detailed worked examples4748Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates.4950## Best Practices5152### Do's5354- **Use $ref** - Reuse schemas, parameters, responses55- **Add examples** - Real-world values help consumers56- **Document errors** - All possible error codes57- **Version your API** - In URL or header58- **Use semantic versioning** - For spec changes5960### Don'ts6162- **Don't use generic descriptions** - Be specific63- **Don't skip security** - Define all schemes64- **Don't forget nullable** - Be explicit about null65- **Don't mix styles** - Consistent naming throughout66- **Don't hardcode URLs** - Use server variables67