EasyDSS流媒体解决方案之接口文档自动生成
来源:互联网 发布:chrome windows 2003 编辑:程序博客网 时间:2024/06/05 11:07
Nodejs项目如何快速快速生成接口文档?
开发过程中,除了定义接口及开发实现,也需要提供专业的文本来描述对外开发的接口,那么我们该怎么快速的提供文档呢?
1. 使用apidoc
npm install apidoc -g
2. 创建apidoc.json
{ "name": "EasyDSS流媒体解决方案API文档", "version": "0.1.0", "description": "", "title": "EasyDSS流媒体解决方案API文档", "url": "", "sampleUrl": "", "header": { "title": "", "filename": "doc/header.md" }, "footer": { "title": "", "filename": "doc/footer.md" }, "template": { "withCompare": true, "withGenerator": true }}
3. grunt配置监听自动化生成
npm i grunt-apidoc --save-dev
在Gruntfile.js添加
grunt.loadNpmTasks('grunt-apidoc');
apidoc: { mypp: { src: "easyums/admin/", dest: "doc/EasyDSS_API/", options: { debug: true, includeFilters: [".*\\.js$"], excludeFilters: ["node_modules/"] } } }
watch中加入监听的js文件
grunt
3. 注释编辑API示列
/** * @api {get} /user/:id Read data of a User * @apiVersion 0.3.0 * @apiName GetUser * @apiGroup User * @apiPermission admin * * @apiDescription Compare Verison 0.3.0 with 0.2.0 and you will see the green markers with new items in version 0.3.0 and red markers with removed items since 0.2.0. * * @apiParam {Number} id The Users-ID. * * @apiExample Example usage: * curl -i http://localhost/user/4711 * * @apiSuccess {Number} id The Users-ID. * @apiSuccess {Date} registered Registration Date. * @apiSuccess {Date} name Fullname of the User. * @apiSuccess {String[]} nicknames List of Users nicknames (Array of Strings). * @apiSuccess {Object} profile Profile data (example for an Object) * @apiSuccess {Number} profile.age Users age. * @apiSuccess {String} profile.image Avatar-Image. * @apiSuccess {Object[]} options List of Users options (Array of Objects). * @apiSuccess {String} options.name Option Name. * @apiSuccess {String} options.value Option Value. * * @apiError NoAccessRight Only authenticated Admins can access the data. * @apiError UserNotFound The <code>id</code> of the User was not found. * * @apiErrorExample Response (example): * HTTP/1.1 401 Not Authenticated * { * "error": "NoAccessRight" * } */function getUser() { return; }/** * @api {post} /user Create a new User * @apiVersion 0.3.0 * @apiName PostUser * @apiGroup User * @apiPermission none * * @apiDescription In this case "apiErrorStructure" is defined and used. * Define blocks with params that will be used in several functions, so you dont have to rewrite them. * * @apiParam {String} name Name of the User. * * @apiSuccess {Number} id The new Users-ID. * * @apiUse CreateUserError */function postUser() { return; }/** * @api {put} /user/:id Change a User * @apiVersion 0.3.0 * @apiName PutUser * @apiGroup User * @apiPermission none * * @apiDescription This function has same errors like POST /user, but errors not defined again, they were included with "apiErrorStructure" * * @apiParam {String} name Name of the User. * * @apiUse CreateUserError */function putUser() { return; }
如果到这里,恭喜已经生成了API文档,在修改中会自动生成!
更多EasyDSS相关功能及版本下载
Web:www.easydss.com
EasyDSS技术交流群:560148162
阅读全文
0 0
- EasyDSS流媒体解决方案之接口文档自动生成
- EasyDSS流媒体解决方案之接口汇总
- EasyDSS RTMP流媒体解决方案之直播录像自动清理方案
- EasyDSS流媒体解决方案之直播流管理
- EasyDSS流媒体解决方案之直播流封面
- EasyDSS流媒体解决方案之视频上传
- EasyDSS流媒体解决方案之点播分享
- EasyDSS流媒体解决方案之Windows服务安装
- EasyDSS流媒体解决方案之直播录像清理
- EasyDSS流媒体解决方案之点播转码进阶
- EasyDSS流媒体解决方案之配置nodejs为windows服务
- EasyDSS流媒体解决方案之Grunt的使用简介
- EasyDSS流媒体解决方案之CDN内容分发网络
- EasyDSS流媒体解决方案之正则表达式的使用
- EasyDSS流媒体解决方案之音频转码支持
- EasyDSS流媒体解决方案之视频多清晰度解决(1)
- EasyDSS流媒体解决方案之Nodejs调用bat或sh脚本
- EasyDSS RTMP流媒体解决方案之Windows服务安装方案
- 机器学习概览
- Linux-centos下安装mysql
- android之在代码中控制视图
- HMM超详细讲解+代码
- 3dmax导出到unity3d下分割动画
- EasyDSS流媒体解决方案之接口文档自动生成
- Java作业-温度转换
- 欢迎使用CSDN-markdown编辑器
- Java多文件上传相关代码
- 资讯精选 |【高盛重磅报告干货解读】中国 AI 剑指全球第一_BAT 实力对比
- Java XSSFWorkbook 抽象工具类
- eclipse下载jboss Tools失败解决办法
- HDU-5900 QSC and Master(区间DP)
- centos6.5编译安装nginx1.6.2+mysql5.5.35+php5.2.17+Zendoptimizer+eaccelerator