api-documentation-generator by sickn33/antigravity-awesome-skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill api-documentation-generator自动从您的代码库生成清晰、全面的 API 文档。此技能帮助您创建专业的文档,包括端点描述、请求/响应示例、身份验证详细信息、错误处理和使用指南。
非常适合 REST API、GraphQL API 和 WebSocket API。
首先,我将检查您的 API 代码库以了解:
对于每个端点,我将创建包含以下内容的文档:
端点详情:
请求规范:
响应规范:
代码示例:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
我将包括:
清晰的错误文档,包括:
在可能的情况下,我将提供:
## 创建用户
创建一个新的用户账户。
**端点:** `POST /api/v1/users`
**身份验证:** 必需(Bearer token)
**请求体:**
\`\`\`json
{
"email": "user@example.com", // 必需:有效的电子邮件地址
"password": "SecurePass123!", // 必需:最少 8 个字符,包含 1 个大写字母,1 个数字
"name": "John Doe", // 必需:2-50 个字符
"role": "user" // 可选:"user" 或 "admin"(默认:"user")
}
\`\`\`
**成功响应(201 Created):**
\`\`\`json
{
"id": "usr_1234567890",
"email": "user@example.com",
"name": "John Doe",
"role": "user",
"createdAt": "2026-01-20T10:30:00Z",
"emailVerified": false
}
\`\`\`
**错误响应:**
- `400 Bad Request` - 无效的输入数据
\`\`\`json
{
"error": "VALIDATION_ERROR",
"message": "Invalid email format",
"field": "email"
}
\`\`\`
- `409 Conflict` - 邮箱已存在
\`\`\`json
{
"error": "EMAIL_EXISTS",
"message": "An account with this email already exists"
}
\`\`\`
- `401 Unauthorized` - 缺少或无效的身份验证令牌
**示例请求(cURL):**
\`\`\`bash
curl -X POST https://api.example.com/api/v1/users \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!",
"name": "John Doe"
}'
\`\`\`
**示例请求(JavaScript):**
\`\`\`javascript
const response = await fetch('https://api.example.com/api/v1/users', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'SecurePass123!',
name: 'John Doe'
})
});
const user = await response.json();
console.log(user);
\`\`\`
**示例请求(Python):**
\`\`\`python
import requests
response = requests.post(
'https://api.example.com/api/v1/users',
headers={
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
},
json={
'email': 'user@example.com',
'password': 'SecurePass123!',
'name': 'John Doe'
}
)
user = response.json()
print(user)
\`\`\`
## 用户查询
根据 ID 获取用户信息。
**查询:**
\`\`\`graphql
query GetUser($id: ID!) {
user(id: $id) {
id
email
name
role
createdAt
posts {
id
title
publishedAt
}
}
}
\`\`\`
**变量:**
\`\`\`json
{
"id": "usr_1234567890"
}
\`\`\`
**响应:**
\`\`\`json
{
"data": {
"user": {
"id": "usr_1234567890",
"email": "user@example.com",
"name": "John Doe",
"role": "user",
"createdAt": "2026-01-20T10:30:00Z",
"posts": [
{
"id": "post_123",
"title": "My First Post",
"publishedAt": "2026-01-21T14:00:00Z"
}
]
}
}
}
\`\`\`
**错误:**
\`\`\`json
{
"errors": [
{
"message": "User not found",
"extensions": {
"code": "USER_NOT_FOUND",
"userId": "usr_1234567890"
}
}
]
}
\`\`\`
## 身份验证
所有 API 请求都需要使用 Bearer token 进行身份验证。
### 获取 Token
**端点:** `POST /api/v1/auth/login`
**请求:**
\`\`\`json
{
"email": "user@example.com",
"password": "your-password"
}
\`\`\`
**响应:**
\`\`\`json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"refreshToken": "refresh_token_here"
}
\`\`\`
### 使用 Token
将 token 包含在 Authorization 头中:
\`\`\`
Authorization: Bearer YOUR_TOKEN
\`\`\`
### Token 过期
Token 在 1 小时后过期。使用刷新 token 获取新的访问 token:
**端点:** `POST /api/v1/auth/refresh`
**请求:**
\`\`\`json
{
"refreshToken": "refresh_token_here"
}
\`\`\`
简介
身份验证
快速开始
端点
数据模型
错误处理
速率限制
更新日志
SDK 和工具
症状: 示例无法工作,参数错误,端点返回不同的数据 解决方案:
症状: 用户不知道如何处理错误,支持工单增加 解决方案:
症状: 用户无法开始使用,挫败感增加 解决方案:
症状: 用户发送无效请求,验证错误 解决方案:
生成交互式文档:
openapi: 3.0.0
info:
title: My API
version: 1.0.0
paths:
/users:
post:
summary: Create a new user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserRequest'
导出集合以便于测试:
{
"info": {
"name": "My API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Create User",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/users"
}
}
]
}
@doc-coauthoring - 用于协作编写文档@copywriting - 用于清晰、用户友好的描述@test-driven-development - 用于确保 API 行为与文档匹配@systematic-debugging - 用于故障排除 API 问题专业提示: 尽可能让您的 API 文档贴近代码。使用从代码注释生成文档的工具,以确保它们保持同步!
每周安装
1.0K
代码仓库
GitHub Stars
27.1K
首次出现
Jan 22, 2026
安全审计
安装于
opencode840
gemini-cli804
codex745
github-copilot711
claude-code673
cursor653
Automatically generate clear, comprehensive API documentation from your codebase. This skill helps you create professional documentation that includes endpoint descriptions, request/response examples, authentication details, error handling, and usage guidelines.
Perfect for REST APIs, GraphQL APIs, and WebSocket APIs.
First, I'll examine your API codebase to understand:
For each endpoint, I'll create documentation including:
Endpoint Details:
Request Specification:
Response Specification:
Code Examples:
I'll include:
Clear error documentation including:
Where possible, I'll provide:
## Create User
Creates a new user account.
**Endpoint:** `POST /api/v1/users`
**Authentication:** Required (Bearer token)
**Request Body:**
\`\`\`json
{
"email": "user@example.com", // Required: Valid email address
"password": "SecurePass123!", // Required: Min 8 chars, 1 uppercase, 1 number
"name": "John Doe", // Required: 2-50 characters
"role": "user" // Optional: "user" or "admin" (default: "user")
}
\`\`\`
**Success Response (201 Created):**
\`\`\`json
{
"id": "usr_1234567890",
"email": "user@example.com",
"name": "John Doe",
"role": "user",
"createdAt": "2026-01-20T10:30:00Z",
"emailVerified": false
}
\`\`\`
**Error Responses:**
- `400 Bad Request` - Invalid input data
\`\`\`json
{
"error": "VALIDATION_ERROR",
"message": "Invalid email format",
"field": "email"
}
\`\`\`
- `409 Conflict` - Email already exists
\`\`\`json
{
"error": "EMAIL_EXISTS",
"message": "An account with this email already exists"
}
\`\`\`
- `401 Unauthorized` - Missing or invalid authentication token
**Example Request (cURL):**
\`\`\`bash
curl -X POST https://api.example.com/api/v1/users \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!",
"name": "John Doe"
}'
\`\`\`
**Example Request (JavaScript):**
\`\`\`javascript
const response = await fetch('https://api.example.com/api/v1/users', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'SecurePass123!',
name: 'John Doe'
})
});
const user = await response.json();
console.log(user);
\`\`\`
**Example Request (Python):**
\`\`\`python
import requests
response = requests.post(
'https://api.example.com/api/v1/users',
headers={
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
},
json={
'email': 'user@example.com',
'password': 'SecurePass123!',
'name': 'John Doe'
}
)
user = response.json()
print(user)
\`\`\`
## User Query
Fetch user information by ID.
**Query:**
\`\`\`graphql
query GetUser($id: ID!) {
user(id: $id) {
id
email
name
role
createdAt
posts {
id
title
publishedAt
}
}
}
\`\`\`
**Variables:**
\`\`\`json
{
"id": "usr_1234567890"
}
\`\`\`
**Response:**
\`\`\`json
{
"data": {
"user": {
"id": "usr_1234567890",
"email": "user@example.com",
"name": "John Doe",
"role": "user",
"createdAt": "2026-01-20T10:30:00Z",
"posts": [
{
"id": "post_123",
"title": "My First Post",
"publishedAt": "2026-01-21T14:00:00Z"
}
]
}
}
}
\`\`\`
**Errors:**
\`\`\`json
{
"errors": [
{
"message": "User not found",
"extensions": {
"code": "USER_NOT_FOUND",
"userId": "usr_1234567890"
}
}
]
}
\`\`\`
## Authentication
All API requests require authentication using Bearer tokens.
### Getting a Token
**Endpoint:** `POST /api/v1/auth/login`
**Request:**
\`\`\`json
{
"email": "user@example.com",
"password": "your-password"
}
\`\`\`
**Response:**
\`\`\`json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"refreshToken": "refresh_token_here"
}
\`\`\`
### Using the Token
Include the token in the Authorization header:
\`\`\`
Authorization: Bearer YOUR_TOKEN
\`\`\`
### Token Expiration
Tokens expire after 1 hour. Use the refresh token to get a new access token:
**Endpoint:** `POST /api/v1/auth/refresh`
**Request:**
\`\`\`json
{
"refreshToken": "refresh_token_here"
}
\`\`\`
Introduction
Authentication
Quick Start
Endpoints
Data Models
Error Handling
Rate Limiting
Changelog
Symptoms: Examples don't work, parameters are wrong, endpoints return different data Solution:
Symptoms: Users don't know how to handle errors, support tickets increase Solution:
Symptoms: Users can't get started, frustration increases Solution:
Symptoms: Users send invalid requests, validation errors Solution:
Generate interactive documentation:
openapi: 3.0.0
info:
title: My API
version: 1.0.0
paths:
/users:
post:
summary: Create a new user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserRequest'
Export collection for easy testing:
{
"info": {
"name": "My API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Create User",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/users"
}
}
]
}
@doc-coauthoring - For collaborative documentation writing@copywriting - For clear, user-friendly descriptions@test-driven-development - For ensuring API behavior matches docs@systematic-debugging - For troubleshooting API issuesPro Tip: Keep your API documentation as close to your code as possible. Use tools that generate docs from code comments to ensure they stay in sync!
Weekly Installs
1.0K
Repository
GitHub Stars
27.1K
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode840
gemini-cli804
codex745
github-copilot711
claude-code673
cursor653
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
Base44 CLI 工具 - 创建和管理 Base44 应用项目 | 命令行开发工具
936 周安装
SwiftUI 开发模式指南:状态管理、视图组合与导航最佳实践
937 周安装
Ant Design 最佳实践指南:React 组件库使用决策、主题配置与性能优化
937 周安装
Grimoire CLI 使用指南:区块链法术编写、验证与执行全流程
940 周安装
Grimoire Uniswap 技能:查询 Uniswap 元数据与生成代币/资金池快照的 CLI 工具
940 周安装
Grimoire Aave 技能:查询 Aave V3 元数据和储备快照的 CLI 工具
941 周安装
SDKs and Tools