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 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-generation
Claude Code
Cursor
Windsurf
Cline

How to use openapi-spec-generation

  1. 1.Review the OpenAPI 3.1 structure and understand the three design approaches (design-first, code-first, hybrid)
  2. 2.Choose your approach based on whether you're building a new API or documenting existing code
  3. 3.Use the schema templates and examples from references/details.md to structure your specification
  4. 4.Define paths, operations, parameters, request/response schemas, and security schemes
  5. 5.Add real-world examples and comprehensive error documentation to each endpoint
  6. 6.Validate your specification against your API implementation or use it to generate SDKs

Use cases

Good for
  • 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
Who it's for
  • 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

Should I write the spec before or after code?

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.

How do I reuse schemas across multiple endpoints?

Use $ref to reference schemas defined in the components/schemas section, avoiding duplication and ensuring consistency.

What should I include in error documentation?

Document all possible HTTP status codes your endpoints can return, with descriptions of when each occurs and example error response bodies.

Do I need to version my OpenAPI spec?

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.

Can I generate client SDKs from my OpenAPI spec?

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

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