安装
npm install -g apidoc
运行
apidoc -i demo/ -o apidoc
apidoc.json 文件
{
"name": "震惊优品",
"version": "1.0.0",
"description": "震惊优品API文档",
"title": "震惊优品API文档",
"url": "https://xxxx.cn/",
"sampleUrl": "https://xxxx.cn/",
"forceLanguage": "zh-cn",
"template": {
"withCompare": true,
"withGenerator": true
}
}
参数说明
示例编写
/**
* @api {get} 接口描述以及请求方式
* @apiVersion 1.0.0
* @apiName demo
* @apiGroup Common
*
* @apiHeader {String} Authori-zation 用户授权token
* @apiHeaderExample {json} Header-Example:
* {
* Authori-zation: 'fdkfjskldafkldsajfklsadklf'
* }
*
* @apiParam {String} param1='hello' 参数说明
* @apiParam {Number = 0,2,3} [number=0] 参数说明
* @apiParam {Number[]} ids 参数说明
*
* @apiParamExample {json} Request-Example:
* {
* param1: 'hello',
* number: 0,
* ids: [1, 2]
* }
*
*
* @apiSuccess {String[]} ids 参数说明
*
* @apiSuccessExample Success-Response:
* {
* ids: ['id1', 'id2']
* }
*/
结果
apiDoc官网: apidocjs.com/