jpskill.com
🛠️ 開発・MCP コミュニティ

openapi-spec

APIの仕様書を作成したり、REST APIを文書化したり、仕様書からSDKを生成したり、APIの契約を検証したり、設計を重視したAPI開発を支援したりするSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

APIの仕様書を作成したり、REST APIを文書化したり、仕様書からSDKを生成したり、APIの契約を検証したり、設計を重視したAPI開発を支援したりするSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o openapi-spec.zip https://jpskill.com/download/15204.zip && unzip -o openapi-spec.zip && rm openapi-spec.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15204.zip -OutFile "$d\openapi-spec.zip"; Expand-Archive "$d\openapi-spec.zip" -DestinationPath $d -Force; ri "$d\openapi-spec.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して openapi-spec.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → openapi-spec フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

OpenAPI仕様

概要

OpenAPI (以前のSwagger) は、REST APIを記述するための標準です。YAML/JSON仕様を一度記述すれば、ドキュメント、クライアントSDK、サーバスタブ、モックサーバ、テストを自動的に生成できます。設計優先の開発により、コードを書く前に破壊的な変更を検出できます。

手順

ステップ 1: API仕様を定義する

# openapi.yaml — API仕様
openapi: 3.1.0
info:
  title: Project Management API
  version: 1.0.0
  description: プロジェクトとタスクを管理するためのAPI

servers:
  - url: https://api.example.com/v1
    description: 本番環境
  - url: http://localhost:3000/v1
    description: ローカル開発

paths:
  /projects:
    get:
      summary: すべてのプロジェクトをリスト表示
      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: 前回のレスポンスからのページネーションカーソル
      responses:
        '200':
          description: プロジェクトのリスト
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Project'
                  nextCursor:
                    type: string
                    nullable: true

    post:
      summary: プロジェクトを作成
      operationId: createProject
      tags: [Projects]
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProjectInput'
      responses:
        '201':
          description: プロジェクトが作成されました
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        '422':
          $ref: '#/components/responses/ValidationError'

  /projects/{projectId}:
    get:
      summary: IDでプロジェクトを取得
      operationId: getProject
      tags: [Projects]
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: プロジェクトの詳細
          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: リソースが見つかりません
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: "Project not found"

    ValidationError:
      description: バリデーションエラー
      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

ステップ 2: TypeScriptクライアントを生成する

npx openapi-typescript openapi.yaml -o src/api/schema.ts
// 生成された型は fetch または 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']

ステップ 3: バリデーションとリント

npx @redocly/cli lint openapi.yaml
npx @redocly/cli preview-docs openapi.yaml  # ライブプレビュー

ガイドライン

  • 設計優先: 実装する前に仕様を記述します。コードよりもYAMLを変更する方が安価です。
  • $refを広範囲に使用します。再利用可能なスキーマは、重複と不整合を防ぎます。
  • すべてのエンドポイントにoperationIdを追加します。これはSDKメソッド名に使用されます。
  • RedoclyまたはStoplightを使用して、視覚的な仕様編集とドキュメントホスティングを行います。
  • 破壊的な変更の場合はURLパス (/v1/) でAPIをバージョン管理し、マイナーアップデートの場合は仕様のversionを使用します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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.