apidoc 基本使用
https://apidocjs.com/#param-api-success-example
- 安装apidoc
npm i apidoc -g
在项目根配置apidoc.json
{
"name": "王者农药后端接口api",
"version": "0.1.0",
"description": "史上最牛逼的接口文档,你值得拥有",
"title": "hero",
"url": "http://127.0.0.1:3000"
}配置接口的注解(一定要写到文件夹中的某个js文件)
如: doc/index.js
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
- 通过命令生成接口文档
apidoc -i ./doc -o ./doc