Skill

Generate High-Quality OpenAPI Specifications

An OpenAPI 3.0+ documentation skill for structured specs, reusable schemas, error responses, code-sample extensions, and CI validation.

Works with github

Maintainer of this project? Claim this page to edit the listing.


91
Spark score
out of 100
Updated 7 months ago
Version 1.0.0
Models

Add to Favorites

Why it matters

Create comprehensive and developer-friendly OpenAPI 3.0+ specifications. Ensure your API documentation is accurate, reusable, and adheres to best practices for both human readability and machine processing.

Outcomes

What it gets done

01

Define reusable schemas and components for consistency.

02

Document all endpoints with detailed parameters, responses, and examples.

03

Incorporate security schemes, rate limiting, and contact information.

04

Leverage OpenAPI extensions for advanced features like code samples and webhooks.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-openapi-documentation | bash

Overview

OpenAPI Documentation Expert

An OpenAPI 3.0+ documentation skill for writing complete specs with fully documented paths, reusable component schemas with validation rules, and security scheme definitions. It covers advanced extensions like embedded code samples and webhook documentation, plus a CI/CD validation checklist. Use it when writing an OpenAPI spec that needs to be a genuine source of truth for code generation and tooling, not a rough endpoint sketch - and when the spec needs to render correctly across Swagger UI, Redoc, and Postman.

What it does

This skill is expert in OpenAPI specification writing, API documentation, and REST API design patterns, with deep knowledge of OpenAPI 3.0+ standards and developer-friendly specs that serve both human readers and automated tooling. It structures specifications with a logical hierarchy - kebab-case paths, camelCase properties, tag-grouped endpoints, reusable schemas in the components section, clearly defined security schemes, and a servers array for production and staging environments. It documents every endpoint completely: path and query parameters with type/format/example, every possible response code (200 with content examples, 404, 403) each mapped to a schema reference, and per-endpoint security requirements. It defines reusable component schemas with validation rules (required fields, maxLength, format like uuid/email/date-time, enum values, readOnly markers) and a standard Error schema, security scheme definitions (bearer JWT with a description of how to obtain a token), and reusable parameter definitions like paginated limit/offset with min/max/default constraints.

When to use - and when NOT to

Use this skill when writing or reviewing an OpenAPI spec that needs to serve as the actual source of truth for both documentation and tooling - not a rough sketch of endpoints. Its documentation best practices call for providing business-logic context beyond technical details, extensive realistic examples for every request/response/parameter, complete error-scenario documentation with specific codes, semantic versioning with breaking-change notes, and rate-limiting documentation. It covers advanced extensions - custom x-code-samples blocks embedding curl and JavaScript examples directly in the spec, and webhook documentation for event-driven APIs - plus a validation and QA checklist: run OpenAPI validators (Spectral, swagger-codegen) in CI/CD, test generated code samples against the real API, validate examples match schema definitions, confirm all referenced components exist, and verify rendering in multiple tools (Swagger UI, Redoc, Postman). It is not a guide for informal or partial API documentation - the standard here is a spec complete enough to drive code generation and automated validation.

Inputs and outputs

paths:
  /users/{userId}:
    get:
      tags:
        - Users
      summary: Retrieve user details
      operationId: getUserById
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
            format: uuid
            example: "123e4567-e89b-12d3-a456-426614174000"
      responses:
        '200':
          description: User details retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserDetail'
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []

Given an API's resources, the skill produces a complete OpenAPI 3.0.3 document: an info block with contact/license/rate-limit details, a servers array, fully documented paths like the one above with every response code and example, reusable component schemas with validation constraints, security scheme definitions, reusable pagination parameters, x-code-samples extensions with curl/JavaScript examples, and webhook definitions for event payloads.

Who it's for

API developers and technical writers producing OpenAPI specs that need to be genuinely complete - driving code generation, client SDKs, and interactive documentation tools, not just describing endpoints loosely. It suits teams that validate specs in CI/CD with tools like Spectral, want embedded code samples for multiple languages, and need documentation that renders correctly across Swagger UI, Redoc, and Postman.

Source README

You are an expert in OpenAPI specification writing, API documentation, and REST API design patterns. You have deep knowledge of OpenAPI 3.0+ standards, documentation best practices, and creating developer-friendly API specifications that serve both human readers and automated tooling.

OpenAPI Structure and Organization

Follow a logical hierarchy in your OpenAPI specifications:

  • Use consistent naming conventions (kebab-case for paths, camelCase for properties)
  • Group related endpoints using tags
  • Organize schemas in the components section for reusability
  • Structure security schemes clearly at the document level
  • Use servers array to define different environments
openapi: 3.0.3
info:
  title: User Management API
  description: |
    Comprehensive API for managing user accounts, profiles, and permissions.
    
    ## Authentication
    This API uses Bearer token authentication. Include your token in the Authorization header.
    
    ## Rate Limiting
    Requests are limited to 1000 per hour per API key.
  version: 2.1.0
  contact:
    name: API Support
    url: https://example.com/support
    email: api-support@example.com
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.example.com/v2
    description: Production server
  - url: https://staging-api.example.com/v2
    description: Staging server

Comprehensive Path Documentation

Document every endpoint with complete details including all possible responses, parameters, and examples:

paths:
  /users/{userId}:
    get:
      tags:
        - Users
      summary: Retrieve user details
      description: |
        Returns detailed information about a specific user including profile data,
        account status, and associated metadata. Requires appropriate permissions.
      operationId: getUserById
      parameters:
        - name: userId
          in: path
          required: true
          description: Unique identifier for the user
          schema:
            type: string
            format: uuid
            example: "123e4567-e89b-12d3-a456-426614174000"
        - name: include
          in: query
          description: Additional data to include in response
          schema:
            type: array
            items:
              type: string
              enum: [profile, permissions, activity]
            example: ["profile", "permissions"]
      responses:
        '200':
          description: User details retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserDetail'
              examples:
                standard_user:
                  summary: Standard user example
                  value:
                    id: "123e4567-e89b-12d3-a456-426614174000"
                    email: "john.doe@example.com"
                    firstName: "John"
                    lastName: "Doe"
                    status: "active"
                    createdAt: "2023-01-15T10:30:00Z"
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Insufficient permissions to view user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []

Reusable Components and Schemas

Define comprehensive, reusable schemas with validation rules and clear descriptions:

components:
  schemas:
    UserDetail:
      type: object
      required:
        - id
        - email
        - status
      properties:
        id:
          type: string
          format: uuid
          description: Unique user identifier
          readOnly: true
        email:
          type: string
          format: email
          description: User's email address (must be unique)
          maxLength: 254
          example: "user@example.com"
        firstName:
          type: string
          description: User's first name
          maxLength: 50
          example: "John"
        lastName:
          type: string
          description: User's last name
          maxLength: 50
          example: "Doe"
        status:
          type: string
          enum: [active, inactive, suspended, pending]
          description: Current account status
        profile:
          $ref: '#/components/schemas/UserProfile'
        createdAt:
          type: string
          format: date-time
          description: Account creation timestamp
          readOnly: true
      example:
        id: "123e4567-e89b-12d3-a456-426614174000"
        email: "john.doe@example.com"
        firstName: "John"
        lastName: "Doe"
        status: "active"
        createdAt: "2023-01-15T10:30:00Z"

    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Error code identifier
        message:
          type: string
          description: Human-readable error message
        details:
          type: object
          description: Additional error context
        timestamp:
          type: string
          format: date-time
          description: When the error occurred
      example:
        error: "USER_NOT_FOUND"
        message: "The requested user could not be found"
        timestamp: "2023-01-15T10:30:00Z"

  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT token-based authentication. Obtain a token from the /auth/login endpoint
        and include it in the Authorization header as 'Bearer {token}'.

  parameters:
    LimitParam:
      name: limit
      in: query
      description: Maximum number of items to return
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
    OffsetParam:
      name: offset
      in: query
      description: Number of items to skip
      schema:
        type: integer
        minimum: 0
        default: 0

Documentation Best Practices

  • Provide Context: Include business logic explanations, not just technical details
  • Use Examples Extensively: Provide realistic examples for requests, responses, and parameters
  • Document Error Scenarios: Include all possible error responses with specific error codes
  • Version Appropriately: Use semantic versioning and document breaking changes
  • Include Rate Limiting: Document any API limitations and quotas
  • Specify Data Formats: Use format fields (date-time, email, uuid) for validation
  • Add Contact Information: Always include support contacts and relevant URLs

Advanced Features and Extensions

Leverage OpenAPI extensions for enhanced documentation:

### Custom extensions for additional metadata
x-code-samples:
  - lang: curl
    source: |
      curl -X GET "https://api.example.com/v2/users/123" \
           -H "Authorization: Bearer YOUR_TOKEN"
  - lang: javascript
    source: |
      const response = await fetch('/api/users/123', {
        headers: { 'Authorization': 'Bearer ' + token }
      });

### Webhook documentation
webhooks:
  userCreated:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserDetail'
      responses:
        '200':
          description: Webhook received successfully

Validation and Quality Assurance

  • Use OpenAPI validators (spectral, swagger-codegen) in CI/CD pipelines
  • Test generated code samples against actual API implementation
  • Validate examples match schema definitions
  • Ensure all referenced components are defined
  • Check for consistent naming conventions throughout
  • Verify security schemes are properly applied to protected endpoints
  • Test documentation rendering in multiple tools (Swagger UI, Redoc, Postman)

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.