Skip to content
Back to skills

Openapi Spec Generation Ccf Claude Code Ccf Mark

ASecurity

Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns.

  • 30 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 12, 2026
developmenttypescriptbashnodenodejsexpressapisecuritydocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 12, 2026

npx -y skills add majiayu000/claude-skill-registry-data --skill openapi-spec-generation-ccf-claude-code-ccf-mark --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Openapi Spec Generation Ccf Claude Code Ccf Mark?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Openapi Spec Generation Ccf Claude Code Ccf Mark
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-openapi-spec-generation-ccf-claude-code-ccf-mark-claude-skill-registry-data/badge)](https://www.skillsdirectory.com/skills/majiayu000-openapi-spec-generation-ccf-claude-code-ccf-mark-claude-skill-registry-data)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: openapi-spec-generation
description: Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns.

summary: |
  - Use `openapi: 3.1.0` with JSON Schema support
  - Design-first for new APIs, code-first for existing
  - Structure: info → servers → paths → components
  - Validate with: spectral, openapi-generator validate
  - Generate SDKs: `openapi-generator generate -i spec.yaml -g typescript-axios`

context_cost: high
load_when:
  - 'openapi'
  - 'swagger'
  - 'api documentation'
  - 'api spec'
  - 'sdk generation'

enhances:
  - api-design-principles
---

# OpenAPI Spec Generation

Patterns for creating and validating OpenAPI 3.1 specifications.

## When to Use

- 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

## Core Concepts

### OpenAPI 3.1 Structure

```yaml
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: ...
```

### 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       |

## Quick Reference

### Common Components

```yaml
components:
  schemas:
    User:
      type: object
      required: [id, email]
      properties:
        id: { type: string, format: uuid }
        email: { type: string, format: email }

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

  responses:
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
```

### Authentication Patterns

```yaml
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

security:
  - BearerAuth: []
```

## Validation Commands

```bash
# Validate spec
npx @stoplight/spectral-cli lint openapi.yaml

# Generate TypeScript client
npx openapi-generator-cli generate \
  -i openapi.yaml \
  -g typescript-axios \
  -o ./generated-client

# Generate server stub
npx openapi-generator-cli generate \
  -i openapi.yaml \
  -g nodejs-express-server \
  -o ./generated-server
```

## Best Practices

1. **Use $ref extensively** — DRY principle for schemas
2. **Include examples** — Real data helps consumers
3. **Document errors** — All possible error responses
4. **Version in URL** — `/v1/`, `/v2/` for breaking changes
5. **Use operationId** — Unique, descriptive IDs for SDK generation

---

_For detailed templates, see [templates.md](./templates.md)_
_For validation patterns, see [validation.md](./validation.md)_

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.