Generate and maintain OpenAPI 3.1 specifications from code
Openapi spec generation

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.
--- name: openapi-spec-generation description: 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. --- # OpenAPI Spec Generation Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs. ## When to Use This Skill - Creating API documentation from scratch - Generating OpenAPI specs from existing code - Designing API contracts (design-first approach) - Validating API implementations against specs - Generating client SDKs from specs - Setting up API documentation portals
Overview
Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs.
Manual install (npx, ZIP)
Claude Code
npx skills add wshobson/agents --skill openapi-spec-generation -g -a claude-codeClaude Code (manual)
mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/documentation-generation/skills/openapi-spec-generationWindows (PowerShell)
New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/fc42a797c3e4a3b393f3/openapi-spec-generation.zip" -OutFile "$env:TEMP\openapi-spec-generation.zip"; Expand-Archive "$env:TEMP\openapi-spec-generation.zip" -DestinationPath "$HOME\.claude\skills" -ForceClaude.ai / desktop
Codex, Cursor, other agents
Connects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md2.0 KBreferences/2 files · 23.1 KB
Read the files here
SKILL.md
Show the full text67 lines
OpenAPI Spec Generation
Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs.
When to Use This Skill
- Creating API documentation from scratch
- Generating OpenAPI specs from existing code
- Designing API contracts (design-first approach)
- Validating API implementations against specs
- Generating client SDKs from specs
- Setting up API documentation portals
Core Concepts
1. OpenAPI 3.1 Structure
openapi: 3.1.0
info:
title: API Title
version: 1.0.0
servers:
- url: https://api.example.com/v1
paths:
/resources:
get: ...
components:
schemas: ...
securitySchemes: ...
2. Design Approaches
| Approach | Description | Best For |
|---|---|---|
| Design-First | Write spec before code | New APIs, contracts |
| Code-First | Generate spec from code | Existing APIs |
| Hybrid | Annotate code, generate spec | Evolving APIs |
Templates and detailed worked examples
Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Best Practices
Do's
- Use $ref - Reuse schemas, parameters, responses
- Add examples - Real-world values help consumers
- Document errors - All possible error codes
- Version your API - In URL or header
- Use semantic versioning - For spec changes
Don'ts
- Don't use generic descriptions - Be specific
- Don't skip security - Define all schemes
- Don't forget nullable - Be explicit about null
- Don't mix styles - Consistent naming throughout
- Don't hardcode URLs - Use server variables
| 1 | |
| 2 | name openapi-spec-generation |
| 3 | description 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 | |
| 5 | |
| 6 | # OpenAPI Spec Generation |
| 7 | |
| 8 | Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs. |
| 9 | |
| 10 | ## When to Use This Skill |
| 11 | |
| 12 | Creating API documentation from scratch |
| 13 | Generating OpenAPI specs from existing code |
| 14 | Designing API contracts (design-first approach) |
| 15 | Validating API implementations against specs |
| 16 | Generating client SDKs from specs |
| 17 | Setting up API documentation portals |
| 18 | |
| 19 | ## Core Concepts |
| 20 | |
| 21 | ### 1. OpenAPI 3.1 Structure |
| 22 | |
| 23 | |
| 24 | openapi: 3.1.0 |
| 25 | info: |
| 26 | title: API Title |
| 27 | version: 1.0.0 |
| 28 | servers: |
| 29 | - url: https://api.example.com/v1 |
| 30 | paths: |
| 31 | /resources: |
| 32 | get: ... |
| 33 | components: |
| 34 | schemas: ... |
| 35 | securitySchemes: ... |
| 36 | |
| 37 | |
| 38 | ### 2. Design Approaches |
| 39 | |
| 40 | | 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 | |
| 45 | |
| 46 | ## Templates and detailed worked examples |
| 47 | |
| 48 | Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates. |
| 49 | |
| 50 | ## Best Practices |
| 51 | |
| 52 | ### Do's |
| 53 | |
| 54 | **Use $ref** - Reuse schemas, parameters, responses |
| 55 | **Add examples** - Real-world values help consumers |
| 56 | **Document errors** - All possible error codes |
| 57 | **Version your API** - In URL or header |
| 58 | **Use semantic versioning** - For spec changes |
| 59 | |
| 60 | ### Don'ts |
| 61 | |
| 62 | **Don't use generic descriptions** - Be specific |
| 63 | **Don't skip security** - Define all schemes |
| 64 | **Don't forget nullable** - Be explicit about null |
| 65 | **Don't mix styles** - Consistent naming throughout |
| 66 | **Don't hardcode URLs** - Use server variables |
| 67 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
SkillImplement the result of /to-spec and /to-tickets in codeImplement spec
SkillStop and check this skill before finishing any replyAcademy guide
SkillAnalyze and prioritize a list of feature requests by themeAnalyze feature requests
SkillDesign an employee advocacy programAdvocacy program designer
SkillBuilds and edits a model-driven Power Apps appapp-builder — intent → model-driven app
SkillDirect, build and render premium cinematic motion designCineticMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns