openapi-swagger

Expert skill for OpenAPI/Swagger specification analysis, validation, and documentation generation. Parse and validate specs, detect breaking changes, generate code samples, and lint for best practices.

509 stars

Best use case

openapi-swagger is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Expert skill for OpenAPI/Swagger specification analysis, validation, and documentation generation. Parse and validate specs, detect breaking changes, generate code samples, and lint for best practices.

Teams using openapi-swagger should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/openapi-swagger/SKILL.md --create-dirs "https://raw.githubusercontent.com/a5c-ai/babysitter/main/library/specializations/technical-documentation/skills/openapi-swagger/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/openapi-swagger/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How openapi-swagger Compares

Feature / Agentopenapi-swaggerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Expert skill for OpenAPI/Swagger specification analysis, validation, and documentation generation. Parse and validate specs, detect breaking changes, generate code samples, and lint for best practices.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# OpenAPI/Swagger Skill

Expert skill for OpenAPI/Swagger specification analysis and documentation generation.

## Capabilities

- Parse and validate OpenAPI 3.x and Swagger 2.0 specifications
- Generate API documentation from specs (ReDoc, Swagger UI)
- Detect breaking changes between API versions
- Validate request/response examples against schemas
- Generate code samples in multiple languages
- Lint OpenAPI specs for best practices (Spectral rules)
- Convert between OpenAPI formats (YAML/JSON, version migration)

## Usage

Invoke this skill when you need to:
- Validate and lint OpenAPI specifications
- Generate API reference documentation
- Detect breaking changes between API versions
- Create code samples from API specs
- Migrate between OpenAPI versions

## Inputs

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| specPath | string | Yes | Path to OpenAPI/Swagger spec file |
| action | string | Yes | validate, lint, generate-docs, diff, generate-samples |
| outputDir | string | No | Output directory for generated content |
| targetVersion | string | No | Target OpenAPI version for migration |
| languages | array | No | Languages for code sample generation |
| rulesets | array | No | Spectral ruleset files to apply |

### Input Example

```json
{
  "specPath": "./api/openapi.yaml",
  "action": "lint",
  "rulesets": [".spectral.yaml"],
  "outputDir": "docs/api"
}
```

## Output Structure

### Validation Output

```json
{
  "valid": true,
  "errors": [],
  "warnings": [
    {
      "path": "paths./users.get.responses.200",
      "message": "Response should have a description",
      "severity": "warning"
    }
  ],
  "info": {
    "title": "My API",
    "version": "1.0.0",
    "openApiVersion": "3.1.0"
  }
}
```

### Breaking Changes Output

```json
{
  "breaking": [
    {
      "type": "removed-endpoint",
      "path": "DELETE /users/{id}",
      "description": "Endpoint removed in new version"
    },
    {
      "type": "changed-type",
      "path": "POST /users.requestBody.email",
      "from": "string",
      "to": "object"
    }
  ],
  "nonBreaking": [
    {
      "type": "added-endpoint",
      "path": "GET /users/{id}/profile"
    }
  ]
}
```

## OpenAPI Specification Patterns

### OpenAPI 3.1 Template

```yaml
openapi: 3.1.0
info:
  title: My API
  description: API description with **Markdown** support
  version: 1.0.0
  contact:
    name: API Support
    email: support@example.com
  license:
    name: MIT
    identifier: MIT

servers:
  - url: https://api.example.com/v1
    description: Production
  - url: https://staging-api.example.com/v1
    description: Staging

tags:
  - name: users
    description: User management operations

paths:
  /users:
    get:
      operationId: listUsers
      summary: List all users
      description: Returns a paginated list of users
      tags:
        - users
      parameters:
        - $ref: '#/components/parameters/PageParam'
        - $ref: '#/components/parameters/LimitParam'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
              examples:
                success:
                  $ref: '#/components/examples/UserListExample'
        '401':
          $ref: '#/components/responses/Unauthorized'

components:
  schemas:
    User:
      type: object
      required:
        - id
        - email
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier
        email:
          type: string
          format: email
          description: User email address
        name:
          type: string
          description: Display name
        createdAt:
          type: string
          format: date-time

    UserList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/User'
        pagination:
          $ref: '#/components/schemas/Pagination'

  parameters:
    PageParam:
      name: page
      in: query
      schema:
        type: integer
        minimum: 1
        default: 1

    LimitParam:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20

  responses:
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

security:
  - bearerAuth: []
```

## Spectral Configuration

### .spectral.yaml

```yaml
extends:
  - spectral:oas

rules:
  # Require descriptions
  operation-description: warn
  operation-operationId: error

  # Naming conventions
  operation-operationId-valid-in-url: true
  path-params: error

  # Security
  operation-security-defined: error

  # Custom rules
  path-must-have-tag:
    description: Every path must have at least one tag
    given: $.paths[*][*]
    severity: warn
    then:
      field: tags
      function: length
      functionOptions:
        min: 1

  require-example:
    description: Responses should have examples
    given: $.paths[*][*].responses[*].content[*]
    severity: info
    then:
      field: examples
      function: truthy
```

## Code Sample Generation

### Generated Samples

```javascript
// JavaScript (fetch)
const response = await fetch('https://api.example.com/v1/users', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
  }
});
const data = await response.json();
```

```python
# Python (requests)
import requests

response = requests.get(
    'https://api.example.com/v1/users',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
    }
)
data = response.json()
```

```bash
# cURL
curl -X GET 'https://api.example.com/v1/users' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json'
```

## Workflow

1. **Parse specification** - Load and parse OpenAPI/Swagger file
2. **Validate syntax** - Check for schema compliance
3. **Lint for best practices** - Apply Spectral rules
4. **Generate documentation** - Create ReDoc/Swagger UI output
5. **Generate samples** - Create code examples
6. **Report findings** - Output validation results

## Dependencies

```json
{
  "devDependencies": {
    "@stoplight/spectral-cli": "^6.11.0",
    "swagger-cli": "^4.0.0",
    "@redocly/cli": "^1.0.0",
    "openapi-generator-cli": "^2.7.0",
    "oasdiff": "^1.0.0"
  }
}
```

## CLI Commands

```bash
# Validate spec
npx @redocly/cli lint openapi.yaml

# Spectral linting
npx spectral lint openapi.yaml

# Generate ReDoc documentation
npx @redocly/cli build-docs openapi.yaml -o docs/index.html

# Detect breaking changes
oasdiff breaking old-api.yaml new-api.yaml

# Generate code samples
npx openapi-generator-cli generate -i openapi.yaml -g typescript-fetch -o ./sdk
```

## Best Practices Applied

- Use $ref for reusable components
- Include examples for all schemas
- Document all error responses
- Use semantic versioning
- Include operationId for all operations
- Tag all endpoints
- Provide server URLs for all environments

## References

- OpenAPI Specification: https://spec.openapis.org/oas/latest.html
- Spectral: https://stoplight.io/open-source/spectral
- ReDoc: https://redocly.com/redoc
- Swagger UI: https://swagger.io/tools/swagger-ui/
- OpenAPI Generator: https://openapi-generator.tech/

## Target Processes

- api-doc-generation.js
- api-reference-docs.js
- sdk-doc-generation.js
- docs-testing.js

Related Skills

openapi

509
from a5c-ai/babysitter

OpenAPI/Swagger specification, code generation, documentation, and validation.

swagger-ui-deployer

509
from a5c-ai/babysitter

Deploy interactive API documentation using Swagger UI with custom branding

openapi-validator

509
from a5c-ai/babysitter

Validate OpenAPI specifications for correctness, security, and best practices

openapi-spec-generator

509
from a5c-ai/babysitter

Automated OpenAPI specification generation from code annotations, comments, and interface definitions

openapi-codegen-orchestrator

509
from a5c-ai/babysitter

Orchestrate multi-language SDK generation from OpenAPI specifications. Configure OpenAPI Generator per language, apply custom templates and post-processing, handle edge cases and custom extensions, and validate generated code compilation.

openapi-generator

509
from a5c-ai/babysitter

Generate OpenAPI specifications from code or legacy APIs with schema inference and documentation

process-builder

509
from a5c-ai/babysitter

Scaffold new babysitter process definitions following SDK patterns, proper structure, and best practices. Guides the 3-phase workflow from research to implementation.

Workflow & Productivity

babysitter

509
from a5c-ai/babysitter

Orchestrate via @babysitter. Use this skill when asked to babysit a run, orchestrate a process or whenever it is called explicitly. (babysit, babysitter, orchestrate, orchestrate a run, workflow, etc.)

yolo

509
from a5c-ai/babysitter

Run Babysitter autonomously with minimal manual interruption.

user-install

509
from a5c-ai/babysitter

Install the user-level Babysitter Codex setup.

team-install

509
from a5c-ai/babysitter

Install the team-pinned Babysitter Codex workspace setup.

retrospect

509
from a5c-ai/babysitter

Summarize or retrospect on a completed Babysitter run.