← Back to Skills Marketplace
shenghoo123-png

Api Doc Gen

by shenghoo123-png · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
84
Downloads
0
Stars
2
Active Installs
1
Versions
Install in OpenClaw
/install api-doc-gen
Description
自动从 Flask、Django、FastAPI、Express.js 代码生成统一格式的API文档,支持Markdown、OpenAPI和Postman导出。
README (SKILL.md)

api-doc-gen — API 文档自动生成器

痛点

  • 手写 API 文档费时费力,格式不统一
  • 前后端接口对接时,文档经常滞后于代码
  • 不同项目文档风格不一致,维护成本高
  • Swagger/OpenAPI 写起来复杂,容易出错

场景

  • 写好一个 Flask/Django/FastAPI 接口,直接生成完整 API 文档
  • 根据代码注释自动推断参数类型和返回值
  • 导出 OpenAPI 3.0 (Swagger) JSON/YAML 格式
  • 导出 Markdown 格式给非技术团队查看
  • 导出 Postman Collection 方便调试

定价

  • 免费:基础文档生成(Markdown 格式,单文件)
  • Pro 19元:OpenAPI 3.0 + Postman Collection + 多端点支持
  • Team 49元:批量处理 + HTML 文档站 + 自定义模板

支持框架

  • FastAPI
  • Flask
  • Django DRF
  • Express.js
  • 通用函数/类(基于注释推断)

输出格式

  • --format markdown — Markdown 格式 API 文档
  • --format openapi — OpenAPI 3.0 JSON
  • --format openapi-yaml — OpenAPI 3.0 YAML
  • --format postman — Postman Collection JSON

指令格式

基本用法

api-doc-gen analyze \x3Cfile_or_code> [选项]

示例

# 分析 Python Flask 文件
api-doc-gen analyze app.py --framework flask --format markdown

# 分析 FastAPI 代码
api-doc-gen analyze main.py --framework fastapi --format openapi

# 分析 Express.js 文件
api-doc-gen analyze routes.js --framework express --format postman

# 从代码字符串生成
api-doc-gen analyze "def hello(name: str) -> str: ..." --language python --format markdown

# 批量处理目录
api-doc-gen batch ./api/ --framework fastapi --format openapi -o docs/

字段推断规则

基于 Python type hints / JSDoc / 代码注释自动推断:

  • 参数类型:string, integer, number, boolean, array, object
  • 是否必填:默认必填,有默认值则可选
  • 描述:优先使用注释,其次参数名
  • 格式:email, phone, url, date, datetime 等

内置响应模板

场景 状态码 响应结构
成功 200 {code: 0, data: {}, message: "success"}
创建成功 201 {code: 0, data: {id}, message: "created"}
参数错误 400 {code: 400, data: null, message: "参数错误"}
未授权 401 {code: 401, data: null, message: "未授权"}
服务器错误 500 {code: 500, data: null, message: "服务器错误"}

技术细节

  • 语言:Python 3.8+
  • 依赖:仅标准库(无外部依赖)
  • 安装:pip install -r requirements.txt
  • CLI:基于 argparse
Usage Guidance
Things to check before installing or running: - Dependency mismatch: SKILL.md claims 'standard library only' but requirements.txt includes pyyaml; expect to install at least pyyaml if you run the tool. Decide whether you are comfortable installing that dependency. - Confirm the generator parses code statically (AST/regex) and does NOT execute the supplied code strings. Review generator.py for any use of exec/compile/subprocess or dynamic imports. The CLI reads files and passes them as text to generator functions — if generator executes them, that would be dangerous for untrusted code. - Run the tool and its tests in a sandbox or isolated environment (container/VM) before using it on sensitive projects. The package includes tests (pytest) you can run locally to validate behavior. - Be aware of minor documentation inconsistencies (README mentioning NestJS; SKILL.md not) and the presence of price tiers in SKILL.md—these are not security issues but indicate the project may have been copy-pasted or incompletely edited. - If you need higher confidence, ask the maintainer for provenance (source repo/homepage) or request an explicit statement that user code is never executed and that no network exfiltration occurs. If the source is unknown and you must analyze untrusted code, run the tool only on isolated infrastructure.
Capability Analysis
Type: OpenClaw Skill Name: api-doc-gen Version: 1.0.0 The 'api-doc-gen' skill bundle is a legitimate tool designed to perform static analysis on Python and JavaScript code to generate API documentation (Markdown, OpenAPI, Postman). The code (cli.py, generator.py) uses standard library modules and regex-based parsing without any network access, credential harvesting, or execution of untrusted code. No evidence of prompt injection or malicious intent was found.
Capability Assessment
Purpose & Capability
Name/description match the code: the package is a CLI + generator that parses code and emits Markdown/OpenAPI/Postman. However SKILL.md and README conflict: SKILL.md claims 'only standard library (no external deps)' while requirements.txt lists pyyaml (and README lists NestJS support not present in SKILL.md). The presence of requirements.txt contradicts the 'standard library only' claim and should be resolved.
Instruction Scope
Runtime instructions in SKILL.md are limited to analyzing code files or code strings, batch processing directories, and exporting docs. The CLI reads files and passes code text to the generator functions. There are no instructions to read unrelated system files, export credentials, or send data to external endpoints.
Install Mechanism
There is no install spec in the registry (instruction-only), so nothing will be automatically downloaded. The repository includes requirements.txt listing pyyaml (and tests require pytest). That is consistent with generating YAML output but contradicts the SKILL.md 'standard library only' claim. No high-risk external downloads or URL-based installers are present.
Credentials
The skill declares no required environment variables, no credentials, and no special config paths. The requested surface is proportional to an offline code-analysis tool.
Persistence & Privilege
The skill is not always-on and does not request elevated or persistent platform privileges. It is user-invocable and allows autonomous invocation by the agent (platform default), which is expected for skills.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install api-doc-gen
  3. After installation, invoke the skill by name or use /api-doc-gen
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of api-doc-gen — automatic API documentation generator. - Generates API docs from Flask, Django DRF, FastAPI, and Express.js code. - Supports output in Markdown, OpenAPI 3.0 (JSON/YAML), and Postman Collection. - Automatically infers parameter types and docs from type hints and comments. - Includes built-in API response templates and batch processing. - Offers free and paid plans with feature upgrades.
Metadata
Slug api-doc-gen
Version 1.0.0
License MIT-0
All-time Installs 2
Active Installs 2
Total Versions 1
Frequently Asked Questions

What is Api Doc Gen?

自动从 Flask、Django、FastAPI、Express.js 代码生成统一格式的API文档,支持Markdown、OpenAPI和Postman导出。 It is an AI Agent Skill for Claude Code / OpenClaw, with 84 downloads so far.

How do I install Api Doc Gen?

Run "/install api-doc-gen" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Api Doc Gen free?

Yes, Api Doc Gen is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Api Doc Gen support?

Api Doc Gen is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Api Doc Gen?

It is built and maintained by shenghoo123-png (@shenghoo123-png); the current version is v1.0.0.

💬 Comments