npm install apidoc -g複製代碼
{
"name": "項目名稱",
"version": "1.0.0",
"description": "項目名稱- 接口文檔",
"title": "項目名稱",
"url" : "http://localhost:8080/api",
"sampleUrl": "http://localhost:8080/api",
"header": {
"title": "頂部說明",
"filename": "header.md"
},
"footer": {
"title": "底部說明",
"filename": "footer.md"
},
"order": [
"Error",
"Define",
"PostTitleAndError",
"PostError"
]
}複製代碼
底部說明
1. 底部具體內容說明複製代碼
頂部說明
1. 頂部具體內容說明複製代碼
/**
* @apiDefine personalGroup 我的信息
*/
/**
* @api {post} /v1/register 註冊
* @apiName register
* @apiGroup personalGroup
* @apiDescription 用戶註冊
*
* @apiParam {String} mobile 手機號
* @apiParam {String} password 密碼.
* @apiParam {Int} sms_code 驗證碼.
* @apiParam {Int} invite_code 邀請碼.
*
* @apiSuccess (200) {Number} status 狀態碼 10000表示陳功.
* @apiSuccess (200) {String} msg 提示語.
* @apiSuccess (200) {Json} data 返回數據.
*/
/**
* @api {get} /v1/account 獲取資產
* @apiName getAccount
* @apiGroup publicGroup
* @apiPermission token
*
* @apiParam (headers參數) {String} token 在請求頭headers中添加token信息
*
* @apiHeaderExample {json} Headers:
* {
* "Content-Type": "application/json;charset=UTF-8",
* "token":"sfdasd"
* }
* @apiSuccessExample {json} 正確響應:
* HTTP/1.1 200 OK
* {
* status:10000,
* msg:"發送成功",
* data:{
* ...
* }
* }
* @apiSuccess (200) {number} status 狀態碼 10000表示陳功.
* @apiSuccess (200) {String} msg 提示語.
* @apiSuccess (200) {String} data 返回數據.
*/
複製代碼
apidoc -i src/ -o apidoc/複製代碼
將apidoc中的目錄文件部署到web服務器中便可訪問,生成目錄以下:web