Skip to content
api-spec logo

API仕様書作成エージェント

api-spec

API仕様書作成エージェント。OpenAPI/Swagger形式のAPI定義、リクエスト/レスポンス仕様、認証仕様を作成。キーワード: API仕様, api spec, OpenAPI, Swagger, REST API, エンドポイント.

SKILL.md

Full skill instructions

API仕様書作成エージェント

役割

RESTful APIの仕様書をOpenAPI形式で作成します。

仕様書構成

docs/​api/
├── openapi.yaml             # メインOpenAPI定義
├── schemas/                 # スキーマ定義
│   ├── user.yaml
│   ├── order.yaml
│   └── common.yaml
├── paths/                   # エンドポイント定義
│   ├── auth.yaml
│   ├── users.yaml
│   └── orders.yaml
└── examples/                # リクエスト/レスポンス例
    ├── user-examples.yaml
    └── order-examples.yaml

OpenAPI テンプレート

メイン定義 (openapi.yaml)

openapi: 3.0.3
info:
  title: [プロジェクト名] API
  description: |
    [プロジェクトの説明]

    ## 認証
    Bearer Tokenによる認証を使用します。
    `Authorization: Bearer <token>` ヘッダーを付与してください。

  version: 1.0.0
  contact:
    name: API Support
    email: [email protected]

servers:
  - url: https://api.example.com/​v1
    description: Production
  - url: https://api.staging.example.com/​v1
    description: Staging
  - url: http://localhost:8000/​v1
    description: Development

tags:
  - name: auth
    description: 認証関連
  - name: users
    description: ユーザー管理
  - name: orders
    description: 注文管理

security:
  - bearerAuth: []

paths:
  $ref: './​paths/​_index.yaml'

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

  schemas:
    $ref: './​schemas/​_index.yaml'

  responses:
    BadRequest:
      description: Bad Request
      content:
        application/​json:
          schema:
            $ref: '#/​components/​schemas/​Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/​json:
          schema:
            $ref: '#/​components/​schemas/​Error'
    NotFound:
      description: Not Found
      content:
        application/​json:
          schema:
            $ref: '#/​components/​schemas/​Error'

エンドポイント定義 (paths/​users.yaml)

/​users:
  get:
    tags:
      - users
    summary: ユーザー一覧取得
    description: 登録されているユーザーの一覧を取得します
    operationId: getUsers
    parameters:
      - name: page
        in: query
        description: ページ番号
        schema:
          type: integer
          default: 1
          minimum: 1
      - name: limit
        in: query
        description: 1ページあたりの件数
        schema:
          type: integer
          default: 20
          minimum: 1
          maximum: 100
      - name: status
        in: query
        description: ステータスでフィルタ
        schema:
          type: string
          enum: [active, inactive, suspended]
    responses:
      '200':
        description: 成功
        content:
          application/​json:
            schema:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '../​schemas/​user.yaml#/​User'
                pagination:
                  $ref: '../​schemas/​common.yaml#/​Pagination'
      '401':
        $ref: '../​openapi.yaml#/​components/​responses/​Unauthorized'

  post:
    tags:
      - users
    summary: ユーザー作成
    description: 新規ユーザーを作成します
    operationId: createUser
    security: []  # 認証不要
    requestBody:
      required: true
      content:
        application/​json:
          schema:
            $ref: '../​schemas/​user.yaml#/​CreateUserRequest'
          example:
            email: [email protected]
            password: SecurePass123!
            name: 山田太郎
    responses:
      '201':
        description: 作成成功
        content:
          application/​json:
            schema:
              $ref: '../​schemas/​user.yaml#/​User'
      '400':
        $ref: '../​openapi.yaml#/​components/​responses/​BadRequest'
      '409':
        description: メールアドレス重複
        content:
          application/​json:
            schema:
              $ref: '../​schemas/​common.yaml#/​Error'

/​users/​{userId}:
  get:
    tags:
      - users
    summary: ユーザー詳細取得
    operationId: getUser
    parameters:
      - name: userId
        in: path
        required: true
        description: ユーザーID
        schema:
          type: string
          format: uuid
    responses:
      '200':
        description: 成功
        content:
          application/​json:
            schema:
              $ref: '../​schemas/​user.yaml#/​User'
      '404':
        $ref: '../​openapi.yaml#/​components/​responses/​NotFound'

  put:
    tags:
      - users
    summary: ユーザー更新
    operationId: updateUser
    parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: string
          format: uuid
    requestBody:
      required: true
      content:
        application/​json:
          schema:
            $ref: '../​schemas/​user.yaml#/​UpdateUserRequest'
    responses:
      '200':
        description: 更新成功
        content:
          application/​json:
            schema:
              $ref: '../​schemas/​user.yaml#/​User'

  delete:
    tags:
      - users
    summary: ユーザー削除
    operationId: deleteUser
    parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: string
          format: uuid
    responses:
      '204':
        description: 削除成功

スキーマ定義 (schemas/​user.yaml)

User:
  type: object
  properties:
    id:
      type: string
      format: uuid
      description: ユーザーID
      example: 550e8400-e29b-41d4-a716-446655440000
    email:
      type: string
      format: email
      description: メールアドレス
      example: [email protected]
    name:
      type: string
      description: 表示名
      example: 山田太郎
    status:
      type: string
      enum: [active, inactive, suspended]
      description: ステータス
      example: active
    createdAt:
      type: string
      format: date-time
      description: 作成日時
    updatedAt:
      type: string
      format: date-time
      description: 更新日時
  required:
    - id
    - email
    - name
    - status
    - createdAt
    - updatedAt

CreateUserRequest:
  type: object
  properties:
    email:
      type: string
      format: email
      description: メールアドレス
      maxLength: 255
    password:
      type: string
      format: password
      description: パスワード(8文字以上、英数字記号混在)
      minLength: 8
      maxLength: 100
    name:
      type: string
      description: 表示名
      minLength: 1
      maxLength: 100
  required:
    - email
    - password
    - name

UpdateUserRequest:
  type: object
  properties:
    name:
      type: string
      minLength: 1
      maxLength: 100
    status:
      type: string
      enum: [active, inactive]

共通スキーマ (schemas/​common.yaml)

Error:
  type: object
  properties:
    error:
      type: object
      properties:
        code:
          type: string
          description: エラーコード
          example: "2001"
        message:
          type: string
          description: エラーメッセージ
          example: "Validation failed"
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              message:
                type: string
        traceId:
          type: string
          description: トレースID
          example: "abc123-def456"

Pagination:
  type: object
  properties:
    page:
      type: integer
      description: 現在のページ
      example: 1
    limit:
      type: integer
      description: 1ページあたりの件数
      example: 20
    totalItems:
      type: integer
      description: 総件数
      example: 100
    totalPages:
      type: integer
      description: 総ページ数
      example: 5

API設計ガイドライン

URL設計

パターン用途例
GET /​resources一覧取得GET /​users
GET /​resources/​{id}詳細取得GET /​users/​123
POST /​resources作成POST /​users
PUT /​resources/​{id}全体更新PUT /​users/​123
PATCH /​resources/​{id}部分更新PATCH /​users/​123
DELETE /​resources/​{id}削除DELETE /​users/​123

ステータスコード

コード用途
200成功(GET, PUT, PATCH)
201作成成功(POST)
204成功・レスポンスなし(DELETE)
400バリデーションエラー
401認証エラー
403認可エラー
404リソース未発見
409競合(重複など)
422ビジネスロジックエラー
500サーバーエラー

ページネーション

GET /​users?page=2&limit=20

Response:
{
  "data": [...],
  "pagination": {
    "page": 2,
    "limit": 20,
    "totalItems": 100,
    "totalPages": 5
  }
}

コマンド

# OpenAPI仕様の検証
npx @redocly/​cli lint docs/​api/​openapi.yaml

# ドキュメント生成
npx @redocly/​cli build-docs docs/​api/​openapi.yaml -o docs/​api-docs.html

# モックサーバー起動
npx prism mock docs/​api/​openapi.yaml

# クライアントコード生成
npx openapi-generator-cli generate -i docs/​api/​openapi.yaml -g typescript-axios -o src/​api

出力形式

API仕様書作成時の成果物:

  1. OpenAPI定義: docs/​api/​openapi.yaml
  2. スキーマ定義: docs/​api/​schemas/​*.yaml
  3. パス定義: docs/​api/​paths/​*.yaml
  4. HTMLドキュメント: docs/​api-docs.html(生成)

関連スキル

  • 基本設計書エージェント: API全体設計を参照
  • 詳細設計書エージェント: 内部実装設計と連携
  • 実装エージェント: API仕様に基づいて実装
  • E2Eテストエージェント: APIテストを作成

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View