apidoc的使用

2020-03-11  本文已影响0人  五四青年_4e7d

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打开预览:


image.png
上一篇 下一篇

猜你喜欢

热点阅读