jpskill.com
✍️ ライティング コミュニティ

api-doc-generator

ソースコードを解析して、APIのエンドポイントやデータの形式、認証方法、エラーなどを網羅したAPIドキュメントをOpenAPI形式で自動生成し、サンプルや説明も加えて使いやすいAPIリファレンスを作成するSkill。

📜 元の英語説明(参考)

Generates comprehensive API documentation from source code by analyzing endpoint definitions, request/response schemas, authentication requirements, and error codes. Produces structured docs in OpenAPI-compatible format with examples, parameter descriptions, and usage guides. Use when documenting APIs, generating API reference docs, creating endpoint documentation, or when the user needs API docs from their codebase.

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

一言でいうと

ソースコードを解析して、APIのエンドポイントやデータの形式、認証方法、エラーなどを網羅したAPIドキュメントをOpenAPI形式で自動生成し、サンプルや説明も加えて使いやすいAPIリファレンスを作成するSkill。

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

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して api-doc-generator.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → api-doc-generator フォルダができる
  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 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

APIドキュメントジェネレーター

概要

ソースコードを解析して、包括的で構造化されたAPIドキュメントを生成します。 このスキルは、エンドポイント定義、HTTPメソッド、パラメータ、 リクエスト/レスポンススキーマ、認証要件、およびエラー処理 パターンを抽出し、人間が読めるMarkdownと 機械可読なOpenAPI 3.0 JSON形式の両方でドキュメントを生成します。

どのような時に使うか

  • ユーザーがAPIのドキュメント化またはAPIドキュメントの生成を依頼した場合
  • コードベースに参照ドキュメントが必要なRESTエンドポイントがある場合
  • ドキュメント化されていないAPIを移行し、既存の動作をキャプチャする必要がある場合
  • ソースコードからOpenAPI/Swagger仕様を生成する場合
  • ユーザーが「API docs」、「endpoint documentation」、または「API reference」に言及した場合

使用すべきでない場合:

  • ユーザーが既存のAPIドキュメントを_消費_する必要がある場合(直接読めばよい)
  • APIがすでに完全にドキュメント化されており、ユーザーがそれを呼び出したい場合
  • ユーザーがGraphQLスキーマドキュメントを必要とする場合(構造が異なり、ツールも異なる)
  • タスクがAPI _コード_の記述であり、既存のコードのドキュメント化ではない場合

ワークフロー

1. ルート/エンドポイント定義のスキャン

コードベースからルート登録パターンを検索します。フレームワーク固有の パターンを探します。

フレームワーク 見つけるべきパターン
Express.js app.get()router.post()、パス付きのapp.use()
FastAPI @app.get()@router.post()、パスデコレータ
Django REST urlpatterns@api_view、ViewSetクラス
Spring Boot @GetMapping@PostMapping@RequestMapping
Go (Gin/Chi) r.GET()r.POST()r.Route()
Rails routes.rbresources :、コントローラアクション
NestJS @Get()@Post()@Controller()デコレータ

出力: すべてのエンドポイントとそのファイルロケーションのリスト。

2. HTTPメソッド、パス、およびパラメータの抽出

各エンドポイントについて、以下を抽出します。

  • HTTPメソッド (GET, POST, PUT, PATCH, DELETE)
  • パスパラメータを含むパス (例: /users/:id)
  • リクエスト解析コードからのクエリパラメータ
  • バリデーションまたは型定義からのリクエストボディスキーマ
  • 戻り値またはシリアライザからのレスポンスボディ
  • コンテンツタイプ (JSON, form-data, multipart)

ルート文字列からパスパラメータを解析します。クエリパラメータへのアクセス (req.queryrequest.args@Query)とボディ解析(req.bodyrequest.json()@Body)を探します。

3. リクエスト/レスポンス型の分析

以下から型情報をトレースします。

  • ハンドラで使用されるTypeScriptインターフェース/型
  • Pydanticモデル、dataclass、またはシリアライザ
  • Zod/Joi/Yupバリデーションスキーマ
  • レスポンスにマッピングされるデータベースモデル定義
  • JSDoc/docstringアノテーション

各リクエストボディとレスポンスボディのスキーマを構築します。フィールド名、 型、必須/オプションステータス、および制約(min/max、regex、enum値)を含めます。

4. 認証要件のドキュメント化

以下を探します。

  • ルートに適用されるミドルウェア (authenticaterequireAuthjwt_required)
  • デコレータベースの認証 (@login_required@Depends(get_current_user))
  • ガードクラス (NestJS @UseGuards(AuthGuard))
  • ハンドラコード内のAPIキーチェック
  • OAuthスコープまたはロールベースのアクセス制御

認証スキーム(Bearerトークン、APIキー、セッションクッキー、OAuth2)と それを必要とするエンドポイントをドキュメント化します。ロール/パーミッション要件を メモします。

5. エラーレスポンスドキュメントの生成

エラー処理を分析して、以下をドキュメント化します。

  • バリデーションエラー (400) - 何がトリガーするか、レスポンス形式
  • 認証エラー (401) - 認証が失敗または欠落している場合
  • 認可エラー (403) - パーミッションが拒否されたシナリオ
  • Not foundエラー (404) - リソースが存在しない場合
  • Conflictエラー (409) - 重複するリソース、状態の競合
  • レート制限エラー (429) - レート制限が存在する場合
  • サーバーエラー (500) - 一般的なエラーレスポンス形式

各エラーについて、ステータスコード、エラーレスポンススキーマ、およびトリガーする条件を ドキュメント化します。カスタムエラークラス、エラーミドルウェア、および例外 ハンドラを探します。

6. 使用例の追加

すべてのエンドポイントについて、以下を生成します。

  • リアルなデータを含む完全なリクエストを示すcurlの例
  • リアルなフィールド値を含む成功レスポンスの例
  • 最も一般的な失敗ケースを示すエラーレスポンスの例
  • POST/PUT/PATCHエンドポイントのリクエストボディの例

現実的だが明らかに偽のデータを使用します(例:user@example.comtest@test.comではありません)。すべての必須ヘッダー(Content-Type、Authorization)を含めます。

7. 最終的な構造化された出力の生成

2つの出力ファイルを生成します。

api-docs.md - 人間が読めるMarkdownドキュメント:

# APIリファレンス

## 概要

API、ベースURL、および一般的なパターンの簡単な説明。

## 認証

認証方法、トークン形式、資格情報を含める場所。

## エンドポイント

### リソース名

#### METHOD /path

このエンドポイントが行うことの説明。

**パラメータ:**

| 名前 | In | 型 | 必須 | 説明 |
| ---- | -- | ---- | -------- | ----------- |

**リクエストボディ:**

```json
{ "example": "value" }
```

**レスポンス (200):**

```json
{ "example": "response" }
```

**エラーレスポンス:**

| ステータス | 説明 |
| ------ | ----------- |

**例:**

```bash
curl -X METHOD https://api.example.com/path ...
```

openapi.json - OpenAPI 3.0仕様:

{
  "openapi": "3.0.3",
  "info": { "title": "API Name", "version": "1.0.0" },
  "paths": { "...": {} },
  "components": { "schemas": { "...": {} }, "securitySchemes": { "...": {} } }
}

チェックリスト

  • [ ] すべてのルート/エンドポイントファイルが識別され、スキャンされた
  • [ ] すべてのエンドポイントにHTTPメソッド、パス、および説明がある
  • [ ] パスパラメータ、クエリパラメータ、およびリクエストボディがドキュメント化された
  • [ ] リクエスト/レスポンススキーマにフィールド型と制約が含まれている
  • [ ] エンドポイントごとの認証要件がドキュメント化された
  • [ ] エラーレスポンスがステータスコードとスキーマでドキュメント化された
  • [ ] Eve
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

API Documentation Generator

Overview

Generate comprehensive, structured API documentation by analyzing source code. The skill extracts endpoint definitions, HTTP methods, parameters, request/response schemas, authentication requirements, and error handling patterns, then produces documentation in both human-readable Markdown and machine-readable OpenAPI 3.0 JSON format.

When to use

  • When the user asks to document an API or generate API docs
  • When a codebase has REST endpoints that need reference documentation
  • When migrating undocumented APIs and need to capture existing behavior
  • When generating OpenAPI/Swagger specs from source code
  • When the user mentions "API docs", "endpoint documentation", or "API reference"

Do NOT use when:

  • The user needs to consume existing API docs (just read them directly)
  • The API is already fully documented and the user wants to call it
  • The user needs GraphQL schema docs (different structure, different tool)
  • The task is writing API code, not documenting existing code

Workflow

1. Scan for route/endpoint definitions

Search the codebase for route registration patterns. Look for framework-specific patterns:

Framework Pattern to find
Express.js app.get(), router.post(), app.use() with paths
FastAPI @app.get(), @router.post(), path decorators
Django REST urlpatterns, @api_view, ViewSet classes
Spring Boot @GetMapping, @PostMapping, @RequestMapping
Go (Gin/Chi) r.GET(), r.POST(), r.Route()
Rails routes.rb, resources :, controller actions
NestJS @Get(), @Post(), @Controller() decorators

Output: A list of all endpoints with their file locations.

2. Extract HTTP methods, paths, and parameters

For each endpoint, extract:

  • HTTP method (GET, POST, PUT, PATCH, DELETE)
  • Path including path parameters (e.g., /users/:id)
  • Query parameters from request parsing code
  • Request body schema from validation or type definitions
  • Response body from return statements or serializers
  • Content types (JSON, form-data, multipart)

Parse path parameters from the route string. Look for query parameter access (req.query, request.args, @Query) and body parsing (req.body, request.json(), @Body).

3. Analyze request/response types

Trace type information from:

  • TypeScript interfaces/types used in handlers
  • Pydantic models, dataclasses, or serializers
  • Zod/Joi/Yup validation schemas
  • Database model definitions that map to responses
  • JSDoc/docstring annotations

Build a schema for each request body and response body. Include field names, types, required/optional status, and constraints (min/max, regex, enum values).

4. Document authentication requirements

Look for:

  • Middleware applied to routes (authenticate, requireAuth, jwt_required)
  • Decorator-based auth (@login_required, @Depends(get_current_user))
  • Guard classes (NestJS @UseGuards(AuthGuard))
  • API key checks in handler code
  • OAuth scopes or role-based access control

Document the auth scheme (Bearer token, API key, session cookie, OAuth2) and which endpoints require it. Note any role/permission requirements.

5. Generate error response documentation

Analyze error handling to document:

  • Validation errors (400) - what triggers them, response format
  • Authentication errors (401) - when auth fails or is missing
  • Authorization errors (403) - permission denied scenarios
  • Not found errors (404) - when resources don't exist
  • Conflict errors (409) - duplicate resources, state conflicts
  • Rate limit errors (429) - if rate limiting is present
  • Server errors (500) - generic error response format

For each error, document the status code, error response schema, and conditions that trigger it. Look for custom error classes, error middleware, and exception handlers.

6. Add usage examples

For every endpoint, generate:

  • A curl example showing a complete request with realistic data
  • A success response example with realistic field values
  • An error response example showing the most common failure case
  • Request body examples for POST/PUT/PATCH endpoints

Use realistic but obviously fake data (e.g., user@example.com, not test@test.com). Include all required headers (Content-Type, Authorization).

7. Produce final structured output

Generate TWO output files:

api-docs.md - Human-readable Markdown documentation:

# API Reference

## Overview

Brief description of the API, base URL, and common patterns.

## Authentication

How to authenticate, token format, where to include credentials.

## Endpoints

### Resource Name

#### METHOD /path

Description of what this endpoint does.

**Parameters:**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |

**Request Body:**

```json
{ "example": "value" }
```

**Response (200):**

```json
{ "example": "response" }
```

**Error Responses:**

| Status | Description |
| ------ | ----------- |

**Example:**

```bash
curl -X METHOD https://api.example.com/path ...
```

openapi.json - OpenAPI 3.0 specification:

{
  "openapi": "3.0.3",
  "info": { "title": "API Name", "version": "1.0.0" },
  "paths": { "...": {} },
  "components": { "schemas": { "...": {} }, "securitySchemes": { "...": {} } }
}

Checklist

  • [ ] All route/endpoint files identified and scanned
  • [ ] Every endpoint has HTTP method, path, and description
  • [ ] Path parameters, query parameters, and request bodies documented
  • [ ] Request/response schemas include field types and constraints
  • [ ] Authentication requirements documented per-endpoint
  • [ ] Error responses documented with status codes and schemas
  • [ ] Every endpoint has at least one curl example
  • [ ] POST/PUT/PATCH endpoints have request body examples
  • [ ] Output includes both api-docs.md and openapi.json
  • [ ] OpenAPI spec is valid (correct structure, $ref usage)

Example

Input: Express.js route file

// routes/users.js
const express = require("express");
const router = express.Router();
const { authenticate } = require("../middleware/auth");
const { validate } = require("../middleware/validate");
const { body, param, query } = require("express-validator");

// GET /api/users - List users with pagination
router.get("/", authenticate, [
  query("page").optional().isInt({ min: 1 }).toInt(),
  query("limit").optional().isInt({ min: 1, max: 100 }).toInt(),
  query("role").optional().isIn(["admin", "user", "moderator"]),
], async (req, res) => {
  const { page = 1, limit = 20, role } = req.query;
  const users = await User.find(role ? { role } : {})
    .skip((page - 1) * limit)
    .limit(limit);
  const total = await User.countDocuments(role ? { role } : {});
  res.json({ users, total, page, limit });
});

// POST /api/users - Create a new user
router.post(
  "/",
  authenticate,
  [
    body("email").isEmail().normalizeEmail(),
    body("name").trim().isLength({ min: 2, max: 100 }),
    body("role").isIn(["admin", "user", "moderator"]),
    body("password").isLength({ min: 8 }),
  ],
  validate,
  async (req, res) => {
    const existing = await User.findOne({ email: req.body.email });
    if (existing) {
      return res.status(409).json({ error: "Email already registered" });
    }
    const user = await User.create(req.body);
    res.status(201).json({ user: user.toPublic() });
  },
);

// GET /api/users/:id - Get user by ID
router.get(
  "/:id",
  authenticate,
  [param("id").isMongoId()],
  validate,
  async (req, res) => {
    const user = await User.findById(req.params.id);
    if (!user) {
      return res.status(404).json({ error: "User not found" });
    }
    res.json({ user: user.toPublic() });
  },
);

Output: (excerpt from api-docs.md)

# API Reference

## Authentication

All endpoints require a Bearer token in the Authorization header:

    Authorization: Bearer <your-jwt-token>

## Endpoints

### Users

#### GET /api/users

List users with optional filtering and pagination.

**Query Parameters:**

| Name  | Type    | Required | Default | Description                               |
| ----- | ------- | -------- | ------- | ----------------------------------------- |
| page  | integer | No       | 1       | Page number (minimum: 1)                  |
| limit | integer | No       | 20      | Results per page (1-100)                  |
| role  | string  | No       | -       | Filter by role: admin, user, or moderator |

**Response (200 OK):**

```json
{
  "users": [
    {
      "id": "507f1f77bcf86cd799439011",
      "email": "jane@example.com",
      "name": "Jane Smith",
      "role": "admin"
    }
  ],
  "total": 42,
  "page": 1,
  "limit": 20
}
```

**Error Responses:**

| Status | Condition             | Body                                     |
| ------ | --------------------- | ---------------------------------------- |
| 401    | Missing/invalid token | `{ "error": "Unauthorized" }`            |
| 422    | Invalid query params  | `{ "errors": [{ "param": "...", ... }]}` |

**Example:**

```bash
curl -H "Authorization: Bearer eyJhbG..." \
  "https://api.example.com/api/users?page=1&limit=10&role=admin"
```

---

#### POST /api/users

Create a new user account.

**Request Body:**

| Field    | Type   | Required | Constraints                    |
| -------- | ------ | -------- | ------------------------------ |
| email    | string | Yes      | Valid email format             |
| name     | string | Yes      | 2-100 characters               |
| role     | string | Yes      | One of: admin, user, moderator |
| password | string | Yes      | Minimum 8 characters           |

```json
{
  "email": "jane@example.com",
  "name": "Jane Smith",
  "role": "user",
  "password": "secureP@ss123"
}
```

**Response (201 Created):**

```json
{
  "user": {
    "id": "507f1f77bcf86cd799439011",
    "email": "jane@example.com",
    "name": "Jane Smith",
    "role": "user"
  }
}
```

**Error Responses:**

| Status | Condition             | Body                                      |
| ------ | --------------------- | ----------------------------------------- |
| 401    | Missing/invalid token | `{ "error": "Unauthorized" }`             |
| 409    | Email already exists  | `{ "error": "Email already registered" }` |
| 422    | Validation failed     | `{ "errors": [{ "param": "...", ... }]}`  |

**Example:**

```bash
curl -X POST https://api.example.com/api/users \
  -H "Authorization: Bearer eyJhbG..." \
  -H "Content-Type: application/json" \
  -d '{"email":"jane@example.com","name":"Jane Smith","role":"user","password":"secureP@ss123"}'
```

Common mistakes

Mistake Fix
Missing error responses Check every res.status() call and error middleware. Document ALL non-2xx responses, not just the happy path.
Undocumented auth requirements Trace middleware chains. If authenticate is applied to a router, ALL sub-routes require auth.
No request/response examples Generate examples for every endpoint. Use realistic data, not "string" or "test".
Ignoring query parameters Search for req.query, request.args, @Query() — these are often undocumented.
Missing parameter constraints Document min/max, regex patterns, enum values — not just the type.
Incomplete OpenAPI spec Validate the JSON against the OpenAPI 3.0 schema. Common gaps: missing required arrays, wrong $ref paths.
Documenting internal routes Skip health checks, metrics endpoints, and internal admin routes unless explicitly requested.
Inconsistent formatting Use the same table structure and section order for every endpoint. Consistency aids scanning.

Quick reference

Operation How
Find Express routes Search for router.get\|post\|put\|delete\|patch
Find FastAPI routes Search for @app.get\|post\|put\|delete\|patch or @router.
Find auth middleware Search for authenticate, requireAuth, jwt_required, @login_required
Find validation Search for body(), param(), query(), Zod schemas, Pydantic models
Find error handling Search for res.status(4, raise HTTP, throw new, custom error classes
Build OpenAPI paths One entry per unique path, methods nested under path object
Build OpenAPI schemas Extract from TypeScript types, Pydantic models, or validation schemas

Key principles

  1. Document every parameter - Every path param, query param, header, and body field must appear in the docs. Undocumented parameters are the #1 source of API integration bugs.

  2. Include realistic examples - Every endpoint needs a curl example with realistic (but fake) data, a success response, and at least one error response. Developers copy-paste from docs; make it work.

  3. Show error cases explicitly - Document every error status code with its trigger condition and response body. Developers spend more time debugging errors than writing happy-path code.

  4. Maintain consistent structure - Every endpoint section must follow the same format: description, parameters table, request body, response, errors, example. Consistency lets developers scan quickly.

  5. Dual output format - Always produce both human-readable Markdown and machine-readable OpenAPI JSON. The Markdown is for developers reading docs; the OpenAPI spec is for tooling (Postman, SDK generators, API gateways).