1.全局下载:
npm install apidoc -g
2.创建api文件夹:
一般都是一级目录创建api文件夹
3.在目标文件接口上方注释:
/**
* @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.
*/
4.cd到当前目录打开,或者右键powershell打开运行:
apidoc -i ./ -o ../api 第一个./是当前目录,../是到入口的app文件夹中
5.按需要修改:
/**
* @api {post} /user/reg 用户注册
* @apiName 用户注册
* @apiGroup User
*
* @apiParam {String} us 用户名.
* @apiParam {String} ps 用户密码.
* @apiParam {String} code 邮箱验证码.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
6.在api文件夹中生成了index.html打开预览:
![](https://img.haomeiwen.com/i20168422/d1fa0be02b497403.png)
网友评论