什么是apidoc?
看着别人某某开放平台提供的api接口文档怎么那么清晰,其实我们自己也可以做到,几句命令行就可以了。
apidoc是一款可以由源代码中的注释直接自动生成api接口文档的工具,它几乎支持目前主流的所有风格的注释。
怎么安装?
1)安装nodejs(默认大家都会nodejs)
2)npm install apidoc –g
3)apidoc -i example/ -o doc/
-i 代码文件夹
-o 输出Api文档的路径
怎么编写接口文档
/**
* @api {post} /auth/register.api app注册
* @apiGroup Auth
* @apiPermission none
* @apiParam {String} type 注册类型(username)
* @apiParam {String} identifier 唯一标识
* @apiParam {String} credential 凭证
* @apiVersion 0.0.1
* @apiSuccessExample {json} Success-Response:
* {
* "status": "success",
* "code": 200,
* "message": "注册成功",
* "data": null
* }
* @apiErrorExample {json} Error-Response:
* {
* "status": "error",
* "code": 400,
* "message": "用户名已经存在"
* }
*/
public function register(Request $request)
{
//...
}
这是在php中写注释的方法,其他语言请访问官网:传送门
做出来是什么样呢?

网友评论