关于 api-docs
api-docs 是用于编写 API 文档和 OpenAPI 规范的技能,适合需要整理接口参考、指南、模式或 Postman 集合的 API 作者。
主要功能
- 01创建 OpenAPI 规范
- 02组织 API 参考文档
- 03记录身份验证与错误
- 04生成 SDK 文档
- 05创建 Postman 集合
适用场景
- 01编写新 API 文档
- 02根据代码生成 API 文档
- 03创建 OpenAPI 或 Swagger 规范
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ htlin222/ dotfiles --skill api-docs安装后在 Claude Code 中输入/api-docs确认已加载。
详细介绍
API 文档
创建全面的 API 文档和 OpenAPI 规范。
适用场景
- 编写新 API 的文档
- 创建 OpenAPI/Swagger 规范
- 生成 SDK 文档
- 编写 API 指南
- 创建 Postman 集合
OpenAPI 模板
openapi: 3.0.3
info:
title: API Name
version: 1.0.0
description: API description
servers:
- url: https://api.example.com/v1
description: Production
paths:
/users:
get:
summary: List users
operationId: listUsers
parameters:
- name: limit
in: query
schema:
type: integer
default: 20
responses:
"200":
description: Success
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/User"
post:
summary: Create user
operationId: createUser
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateUser"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/User"
components:
schemas:
User:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
email:
type: string
format: email
required:
- id
- name
- email
CreateUser:
type: object
properties:
name:
type: string
email:
type: string
format: email
required:
- name
- email
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- bearerAuth: []
文档结构
# API Reference
## Authentication
All requests require a Bearer token in the Authorization header.
## Endpoints
### Users
#### List Users
`GET /users`
**Parameters:**
| Name | Type | Required | Description |
| ----- | ------- | -------- | ---------------- |
| limit | integer | No | Results per page |
**Response:**
```json
[{ "id": "...", "name": "...", "email": "..." }]
```
#### Create User
`POST /users`
**Request Body:**
```json
{ "name": "John", "email": "[email protected]" }
```
## Error Codes
| Code | Description |
| ---- | --------------------- |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |
| 500 | Internal Server Error |
示例
输入:“编写用户 API 的文档” **操作:**创建 OpenAPI 规范,包含所有端点、架构、示例和错误代码
输入:“根据代码生成 API 文档” **操作:**提取端点、推断类型并创建结构化文档
评论
支持 Markdown