openapi-spec-generation
wshobson/agents
Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns.
What is openapi-spec-generation?
This skill provides patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs. Use it when documenting APIs, generating SDKs, designing API contracts, or ensuring implementations comply with specifications.
- Generate OpenAPI specs from existing code or design-first specifications
- Validate API implementations against OpenAPI contracts
- Create reusable schema components and security definitions
- Document error codes and response patterns comprehensively
- Support design-first, code-first, and hybrid specification approaches
- Generate client SDKs from completed specifications
How to install openapi-spec-generation
npx skills add https://github.com/wshobson/agents --skill openapi-spec-generationHow to use openapi-spec-generation
- 1.Review the OpenAPI 3.1 structure and understand the three design approaches (design-first, code-first, hybrid)
- 2.Choose your approach based on whether you're building a new API or documenting existing code
- 3.Use the schema templates and examples from references/details.md to structure your specification
- 4.Define paths, operations, parameters, request/response schemas, and security schemes
- 5.Add real-world examples and comprehensive error documentation to each endpoint
- 6.Validate your specification against your API implementation or use it to generate SDKs
Use cases
- Creating API documentation from scratch for a new REST service
- Generating OpenAPI specs from an existing codebase to establish contracts
- Designing API contracts before implementation using design-first methodology
- Validating that an API implementation matches its OpenAPI specification
- Generating type-safe client SDKs from a finalized OpenAPI spec
- API developers and architects
- Backend engineers building REST APIs
- Technical writers documenting APIs
- SDK maintainers and library authors
- Teams practicing contract-driven development
openapi-spec-generation FAQ
Use design-first for new APIs and contracts, code-first for existing APIs, or hybrid for evolving APIs. Design-first helps catch issues early; code-first documents what exists.
Use $ref to reference schemas defined in the components/schemas section, avoiding duplication and ensuring consistency.
Document all possible HTTP status codes your endpoints can return, with descriptions of when each occurs and example error response bodies.
Yes—use semantic versioning for spec changes and include the version in your info section. Consider versioning your API itself in the URL or headers.
Yes—once your spec is complete and validated, tools can generate type-safe client libraries in multiple languages from the specification.
Full instructions (SKILL.md)
Source of truth, from wshobson/agents.
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
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
Related skills
More from wshobson/agents and the wider catalog.

parallel-debugging
Debug complex issues systematically using competing hypotheses and parallel investigation.

parallel-feature-development
Coordinate parallel feature development with file ownership strategies and conflict avoidance rules for multi-agent teams.

paypal-integration
Integrate PayPal payments with express checkout, subscriptions, and refund management.

pci-compliance
Implement PCI DSS compliance for secure payment card handling and processing.

postgresql-table-design
Design PostgreSQL schemas with best-practices for data types, indexing, constraints, and performance.

postmortem-writing
Write blameless postmortems with root cause analysis, timelines, and action items to drive organizational learning.