Openapi specification

From NickCrew/Claude-Cortex · View interactive version

Openapi specification is an AI agent skill from the GitHub repository NickCrew/Claude-Cortex. OpenAPI 3.x specification design, schema patterns, and validation for REST API contracts. Use when creating or maintaining API specifications, generating documentation, or validating API contracts.

How to use this skill

Skill file

OpenAPI Specification

Design, validate, and maintain OpenAPI 3.x specifications for REST API contracts.

Covers schema patterns, security schemes, versioning, and code generation integration.

When to Use This Skill

Quick Reference

| Resource | Purpose | Load when |

|----------|---------|-----------|

| references/spec-patterns.md | Schema patterns, security schemes, validation, versioning, reusable components | Designing or reviewing specs |


Workflow

Phase 1: Design       → Define API overview, resources, and operations
Phase 2: Schema       → Build data models with reusable components
Phase 3: Validate     → Lint and verify the spec for correctness
Phase 4: Integrate    → Generate docs, SDKs, and contract tests

Phase 1: API Design

Start with a high-level design before writing the spec:

  1. Identify resources -- what nouns does this API expose?
  2. Map operations -- what CRUD and custom actions apply to each resource?
  3. Define relationships -- how do resources reference each other?
  4. Plan authentication -- what security schemes are needed?
  5. Set conventions -- naming style, pagination, error format

Spec Skeleton

openapi: 3.1.0
info:
  title: [API Name]
  version: 1.0.0
  description: [What this API does]
paths:
  /resources:
    get:
      summary: List resources
      operationId: listResources
    post:
      summary: Create a resource
      operationId: createResource
  /resources/{id}:
    get:
      summary: Get a resource
      operationId: getResource
components:
  schemas: {}
  securitySchemes: {}

Phase 2: Schema Design

Build data models using components/schemas for reuse:


Phase 3: Validate

Run validation before committing any spec changes:

# Spectral (recommended)
spectral lint openapi.yaml

# Redocly
redocly lint openapi.yaml

# swagger-cli
swagger-cli validate openapi.yaml

Common Validation Issues

| Issue | Fix |

|-------|-----|

| Missing operationId | Add unique operationId to every operation |

| Unused schema | Remove from components or add a $ref |

| Missing response description | Add description to every response code |

| Path parameter not in path | Match {param} in path with parameter definition |

| No 2xx response defined | Add at least one success response per operation |


Phase 4: Integrate

Use the validated spec to generate downstream artifacts:


Quality Checklist


Anti-Patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.