SuperAPI AI Directory

api-doc-generator

Coding & development

View repository

Updated 10-16 06:19

About this skill

API Doc Generator

Generate API documentation from code, supporting REST API, GraphQL, and multiple documentation formats.

Generate API documentation from source code, supporting REST APIs, GraphQL, and various documentation formats.

When to Use

Use this skill when the user requests the following operations:

  • Generate API documentation / Generate API documentation
  • Create interface documentation / Create interface documentation
  • Write API descriptions / Write API descriptions
  • Generate OpenAPI/Swagger specs / Generate OpenAPI/Swagger specs

Instructions

Analysis Steps / Analysis Steps

  1. Identify API type - REST, GraphQL, RPC, etc.
  2. Extract endpoint information - URL, method, parameters
  3. Analyze data structures - Request/response formats
  4. Identify authentication methods - API Key, OAuth, JWT, etc.
  5. Generate documentation - Output in standard format

Documentation Content / Documentation Content

Each API endpoint should include:

  • Endpoint path - URL and HTTP method
  • Description - Function description
  • Parameters - Path parameters, query parameters, request body
  • Response - Success and error response examples
  • Authentication - Authentication requirements

Output Formats / Output Formats

The following documentation formats are supported:

  • Markdown (default) - Use templates/api-doc.md template
  • OpenAPI 3.0 YAML
  • API Blueprint

Use templates/api-doc.md for Markdown output format.

Standard Template / Standard Template

## API 文档 / API Documentation

### 端点概览 / Endpoint Overview

| 方法 | 路径 | 描述 |
|------|------|------|
| GET | /api/resource | 获取资源列表 |

### 详细说明 / Details

#### [方法] /path

**描述**: ...

**请求参数**:
| 参数 | 类型 | 必需 | 描述 |
|------|------|------|------|

**请求示例**:
```json
{}
```

**响应示例**:
```json
{}
```

Examples

Input / Input

from fastapi import FastAPI, HTTPException
from pydantic import BaseModel

app = FastAPI()

class User(BaseModel):
    id: int
    name: str
    email: str

@app.get("/users/{user_id}")
async def get_user(user_id: int) -> User:
    """Get a user by ID."""
    if user_id <= 0:
        raise HTTPException(status_code=404, detail="User not found")
    return User(id=user_id, name="John", email="john@example.com")

@app.post("/users")
async def create_user(user: User) -> User:
    """Create a new user."""
    return user

Output / Output

API documentation

Endpoint overview

Method Path Description
GET /users/{user_id} Get user information by ID
POST /users Create a new user

GET /users/{user_id}

Description: Get user information by user ID

Path parameters:

Parameter Type Required Description
user_id integer ✅ User unique identifier

Response 200 - Success:

{
  "id": 1,
  "name": "John",
  "email": "john@example.com"
}

Response 404 - Not Found:

{
  "detail": "User not found"
}

POST /users

Description: Create a new user

Request body:

Field Type Required Description
id integer ✅ User ID
name string ✅ User name
email string ✅ User email

Request example:

{
  "id": 1,
  "name": "John",
  "email": "john@example.com"
}

Response 200 - Success:

{
  "id": 1,
  "name": "John",
  "email": "john@example.com"
}