PluginBench
Skill
Pass
Audit score 90

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 comprehensive 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
  • Create and maintain OpenAPI 3.1 structure with proper schema organization
  • Validate API implementations against OpenAPI contracts
  • Support design-first, code-first, and hybrid specification approaches
  • Document error codes, security schemes, and server configurations
  • Enable SDK generation and API documentation portal setup

How to install openapi-spec-generation

npx skills add https://github.com/wshobson/agents --skill openapi-spec-generation
Claude Code
Cursor
Windsurf
Cline

How to use openapi-spec-generation

  1. 1.Define your API structure using OpenAPI 3.1 format with proper info, servers, and paths sections
  2. 2.Choose your approach: design-first (spec before code), code-first (generate from code), or hybrid (annotate and generate)
  3. 3.Create reusable schemas in the components section and reference them with $ref throughout your spec
  4. 4.Document all endpoints with descriptions, parameters, request bodies, and response schemas
  5. 5.Define security schemes and error responses for all operations
  6. 6.Validate your spec against OpenAPI 3.1 standards and test with actual API calls
  7. 7.Use the spec to generate SDKs, client libraries, or documentation portals

Use cases

Good for
  • Creating API documentation from scratch for new REST APIs
  • Generating OpenAPI specs from existing codebases
  • Designing API contracts before implementation begins
  • Validating that API implementations match their specifications
  • Generating client SDKs from OpenAPI specifications
Who it's for
  • API developers and architects
  • Backend engineers building REST APIs
  • API product managers designing contracts
  • DevOps engineers managing API documentation
  • SDK maintainers generating client libraries

openapi-spec-generation FAQ

Should I write the spec before or after building my API?

Design-first (spec before code) works best for new APIs and establishing contracts. For existing APIs, use code-first generation. Hybrid approaches work well for evolving APIs where you annotate code and generate specs.

How do I reuse schema definitions across multiple endpoints?

Use $ref to reference schemas defined in the components/schemas section. This keeps your spec DRY and makes updates easier.

What should I include in error documentation?

Document all possible error codes your API can return, including HTTP status codes, error messages, and any error-specific fields. Be explicit about which endpoints return which errors.

How do I handle API versioning in OpenAPI specs?

Include the version in your URL path (e.g., /v1/) or as a header parameter. Use semantic versioning for spec changes and update the version field in the info section.

Can I generate client SDKs from my OpenAPI spec?

Yes. Once you have a valid OpenAPI 3.1 spec, you can use tools and generators to automatically create client libraries in various languages.

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

ApproachDescriptionBest For
Design-FirstWrite spec before codeNew APIs, contracts
Code-FirstGenerate spec from codeExisting APIs
HybridAnnotate code, generate specEvolving 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