Loading...
Loading...
Compare original and translation side by side
undefinedundefinedundefinedundefined| API Type | Tool | Output |
|---|---|---|
| REST API | OpenAPI/Swagger | Interactive API docs |
| GraphQL | GraphQL Schema | Schema documentation |
| JavaScript Library | JSDoc | HTML reference |
| Python Library | Sphinx/pdoc | HTML reference |
| API类型 | 工具 | 输出结果 |
|---|---|---|
| REST API | OpenAPI/Swagger | 交互式API文档 |
| GraphQL | GraphQL Schema | 架构文档 |
| JavaScript库 | JSDoc | HTML参考文档 |
| Python库 | Sphinx/pdoc | HTML参考文档 |
/**
* @swagger
* /users:
* get:
* summary: Get all users
* responses:
* 200:
* description: List of users
*/
router.get('/users', getUsers);npx swagger-jsdoc -d swaggerDef.js routes/*.js -o openapi.json/**
* Adds two numbers together.
* @param {number} a - First number
* @param {number} b - Second number
* @returns {number} Sum of a and b
* @example
* add(2, 3); // returns 5
*/
function add(a, b) {
return a + b;
}def add(a: int, b: int) -> int:
"""Add two numbers together.
Args:
a: First number
b: Second number
Returns:
Sum of a and b
Example:
>>> add(2, 3)
5
"""
return a + b/**
* @swagger
* /users:
* get:
* summary: 获取所有用户
* responses:
* 200:
* description: 用户列表
*/
router.get('/users', getUsers);npx swagger-jsdoc -d swaggerDef.js routes/*.js -o openapi.json/**
* 将两个数字相加。
* @param {number} a - 第一个数字
* @param {number} b - 第二个数字
* @returns {number} a和b的和
* @example
* add(2, 3); // 返回5
*/
function add(a, b) {
return a + b;
}def add(a: int, b: int) -> int:
"""将两个数字相加。
参数:
a: 第一个数字
b: 第二个数字
返回:
a和b的和
示例:
>>> add(2, 3)
5
"""
return a + bundefinedundefined
**JSDoc:**
```bash
npx jsdoc src/ -d docs/ -rsphinx-apidoc -o docs/source mypackage/
cd docs && make htmlpdoc --html --output-dir docs/ mypackage/
**JSDoc:**
```bash
npx jsdoc src/ -d docs/ -rsphinx-apidoc -o docs/source mypackage/
cd docs && make htmlpdoc --html --output-dir docs/ mypackage/docs/
├── api/
│ ├── openapi.json # OpenAPI specification
│ ├── index.html # Interactive API docs
│ └── endpoints/ # Endpoint details
├── reference/
│ ├── classes/ # Class documentation
│ ├── functions/ # Function documentation
│ └── types/ # Type definitions
└── guides/
├── authentication.md # Auth guide
└── examples.md # Usage examplesdocs/
├── api/
│ ├── openapi.json # OpenAPI规范文件
│ ├── index.html # 交互式API文档
│ └── endpoints/ # 端点详情
├── reference/
│ ├── classes/ # 类文档
│ ├── functions/ # 函数文档
│ └── types/ # 类型定义
└── guides/
├── authentication.md # 认证指南
└── examples.md # 使用示例undefinedundefinedundefinedcurl -H "Authorization: Bearer TOKEN" \\
https://api.example.com/v1/usersconst response = await fetch('https://api.example.com/v1/users', {
headers: { 'Authorization': 'Bearer TOKEN' }
});import requests
response = requests.get(
'https://api.example.com/v1/users',
headers={'Authorization': 'Bearer TOKEN'}
)undefinedopenapi: 3.0.0
info:
title: My API
version: 1.0.0
description: API description
servers:
- url: https://api.example.com/v1
paths:
/users:
get:
summary: List users
parameters:
- name: page
in: query
schema:
type: integer
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: integer
name:
type: stringopenapi: 3.0.0
info:
title: My API
version: 1.0.0
description: API描述
servers:
- url: https://api.example.com/v1
paths:
/users:
get:
summary: 列出用户
parameters:
- name: page
in: query
schema:
type: integer
responses:
'200':
description: 请求成功
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: integer
name:
type: string