使用postman
+docgen
生成API接口文档
docgen
github地址:Releases · thedevsaddam/docgen (github.com)
- 下载docgen发布版并将其地址配置到环境变量
path
中 - 从postman中导出
json
格式的接口文档 - 生成api文档
api文档生成指令:
生成html文档:
docgen build -i json文件地址 -o 输出html文件地址名
docgen build -i C:\Users\admin\Desktop\api\api.json -o C:\Users\admin\Desktop\api\api.html
生成markdown文档:
docgen build -i input-postman-collection.json -o 输出md文件地址名 -m
docgen build -i C:\Users\27843\Desktop\图书管理系统\api.json -o C:\Users\27843\Desktop\图书管理系统\api.md -m
查看postman生成的实时html文档:
docgen server -f json文件地址 -p 端口号
docgen server -f C:\Users\admin\Desktop\api\api.json -p 8000
2022/08/25 10:15:23 Listening on port: 8000
2022/08/25 10:15:23 Web Server is available at http://localhost:8000/
查看postman生成的实时markdown文档:
docgen server -f json文件地址 -p 端口号 -m
docgen server -f C:\Users\admin\Desktop\api\api.json -p 8000 -m
2022/08/25 10:19:16 Listening on port: 8000
2022/08/25 10:19:16 Web Server is available at http://localhost:8000/
可以在文件夹内打开cmd 这样就不需要寻找目录了,直接使用文件名生成文档即可
C:\Users\27843\Desktop\图书管理系统>docgen server -f api.json -p 8000 -m
2022/08/25 10:19:16 Listening on port: 8000
2022/08/25 10:19:16 Web Server is available at http://localhost:8000/
^C
C:\Users\27843\Desktop\图书管理系统>docgen server -f api.json -p 8000
2022/08/25 10:22:13 Listening on port: 8000
2022/08/25 10:22:13 Web Server is available at http://localhost:8000/
^C
C:\Users\27843\Desktop\图书管理系统>docgen build -i api.json -o api.html
2022/08/25 10:23:06 Documentation successfully generated to api.html