Skip to content
Skillv1.0.0

openapi-spec

Design and maintain OpenAPI specifications. Use when a user asks to create an API spec, document REST APIs, generate client SDKs from a spec, validate API contracts, or implement design-first API deve

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/openapi-spec/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill openapi-spec. Copyright stays with the author (Apache-2.0).

OpenAPI Specification

Overview

OpenAPI (formerly Swagger) is the standard for describing REST APIs. Write a YAML/JSON spec once, then generate documentation, client SDKs, server stubs, mock servers, and tests automatically. Design-first development catches breaking changes before writing code.

Instructions

Step 1: Define API Spec

# openapi.yaml — API specification
openapi: 3.1.0
info:
  title: Project Management API
  version: 1.0.0
  description: API for managing projects and tasks

servers:
  - url: https://api.example.com/v1
    description: Production
  - url: http://localhost:3000/v1
    description: Local development

paths:
  /projects:
    get:
      summary: List all projects
      operationId: listProjects
      tags: [Projects]
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum: [active, archived, all]
            default: active
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
        - name: cursor
          in: query
          schema:
            type: string
          description: Pagination cursor from previous response
      responses:
        '200':
          description: List of projects
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Project'
                  nextCursor:
                    type: string
                    nullable: true

    post:
      summary: Create a project
      operationId: createProject
      tags: [Projects]
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProjectInput'
      responses:
        '201':
          description: Project created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        '422':
          $ref: '#/components/responses/ValidationError'

  /projects/{projectId}:
    get:
      summary: Get project by ID
      operationId: getProject
      tags: [Projects]
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Project details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        '404':
          $ref: '#/components/responses/NotFound'

components:
  schemas:
    Project:
      type: object
      required: [id, name, status, createdAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          example: "Website Redesign"
        description:
          type: string
          nullable: true
        status:
          type: string
          enum: [active, archived]
        taskCount:
          type: integer
        createdAt:
          type: string
          format: date-time

    CreateProjectInput:
      type: object
      required: [name]
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
        description:
          type: string
          maxLength: 500

  responses:
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: "Project not found"

    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              details:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                    message:
                      type: string

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

Step 2: Generate TypeScript Client

npx openapi-typescript openapi.yaml -o src/api/schema.ts
// Generated types are used with fetch or axios
import type { paths } from './schema'

type ListProjectsResponse = paths['/projects']['get']['responses']['200']['content']['application/json']
type CreateProjectInput = paths['/projects']['post']['requestBody']['content']['application/json']

Step 3: Validate and Lint

npx @redocly/cli lint openapi.yaml
npx @redocly/cli preview-docs openapi.yaml  # live preview

Guidelines

  • Design-first: write the spec before implementing. It's cheaper to change YAML than code.
  • Use $ref extensively — reusable schemas prevent duplication and inconsistency.
  • Add operationId to every endpoint — it's used for SDK method names.
  • Use Redocly or Stoplight for visual spec editing and documentation hosting.
  • Version your API in the URL path (/v1/) for breaking changes; use spec version for minor updates.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-openapi-spec/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-openapi-spec.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-openapi-spec",
  "kind": "skill",
  "name": "openapi-spec",
  "description": "Design and maintain OpenAPI specifications. Use when a user asks to create an API spec, document REST APIs, generate client SDKs from a spec, validate API contracts, or implement design-first API development.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "openapi",
      "swagger",
      "api-design",
      "documentation",
      "rest",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Design and maintain OpenAPI specifications. Use when a user asks to create an API spec, document REST APIs, generate client SDKs from a spec, validate API contracts, or implement design-first API development."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/openapi-spec/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/openapi-spec/SKILL.md",
      "key": "terminalskills/skills/skills/openapi-spec/SKILL.md"
    },
    "compatibility": "Any language, any framework",
    "license": "Apache-2.0"
  },
  "instructions": "# OpenAPI Specification\n\n## Overview\n\nOpenAPI (formerly Swagger) is the standard for describing REST APIs. Write a YAML/JSON spec once, then generate documentation, client SDKs, server stubs, mock servers, and tests automatically. Design-first development catches breaking changes before writing code.\n\n## Instructions\n\n### Step 1: Define API Spec\n\n```yaml\n# openapi.yaml — API specification\nopenapi: 3.1.0\ninfo:\n  title: Project Management API\n  version: 1.0.0\n  description: API for managing projects and tasks\n\nservers:\n  - url: https://api.example.com/v1\n    description: Production\n  - url: http",
  "cost": {
    "context_tokens": 1351
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-openapi-spec/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.