日常开发总会需要接口文档编写,如果使用word之类的不好编写,外观也不好看,文档生成工具有很多,apidoc还是不错的
apiDoc介绍
Git地址:https://github.com/apidoc/apidoc
apidoc地址:http://apidocjs.com/
- 简单做了个测试预览效果
http://doc.vueyun.com/
- apidoc是基于nodeJs平台,在安装apidoc之前,需要先安装nodeJs, 修改node的淘宝镜像
http://blog.csdn.net/qq_34827048/article/details/78227624
- 全局安装apidoc
npm install apidoc -g
或
cnpm install apidoc -g
- 在项目下创建apidoc.json文件
{
"name": "小小接口文档",
"version": "1.0.0",
"description": "小程序项目接口文档,通过Laravel5.4实现",
"title": "接口文档",
"private": true,
"sampleUrl": " ",
}
- 样码示例
/**
* @api {post} http://doc.vueyun.com/list 添加数据
* @apiName postAdd
* @apiVersion 1.0.0
* @apiGroup Auth
*
* @apiParam {String} name 名称
* @apiParam {String} desc 描述
* @apiParam {integer} status 状态,0为关闭,1为开启
*
* @apiParamExample {urlencode} Request Example (UrlEncode)
* ?name=丽丽&desc=我的&status=0
* @apiParamExample {yaml} Request Example (YAML)
* name:丽丽,
* desc:我的,
* status:0
*
*
* @apiSuccess {Object[]} data 返回的数据
* @apiSuccess {Integer} result 修改结果
*
* @apiSuccessExample {yaml} Success Response Example
* status: true,
* code: 200,
* message: "成功",
* data:{
* "massage": "添加成功",
* }
*/
- 运行命令: apidoc既可查看
- 注:具体参数意思使用自行参照文档编写