使用rest framerok時,需要寫API接口文檔,此時就需要用到 apidoc(個人覺得這個用的比較順手)
需要安裝nodejs,,,
windows 下
1 然后驗證是否安裝成功 node -v
2 安裝完nodejs環境后,會自帶npm,npm為nodejs包管理工具,安裝apidoc :npm install apidoc -g,
安裝完成后,使用apidoc -h,查看是否安裝成功
3 C:\nodejs\ex>apidoc -i c://nodejs/ex/ -o apidoc/ [使用,apidoc.json一定要放在同級目錄]


{ "name": "apidoc-example", "version": "0.3.0", "description": "apiDoc example project", "title": "Custom apiDoc browser title", "url" : "https://api.github.com/v1" }
/**
* @api {post} ([v1|v2]+)/reply/(\d+)$ [post]回復單篇文章
* @apiName post_id_reply
* @apiGroup Get_reply
* @apiSuccessExample Response (example):
* HTTP/1.1 200
回復文章的評論
{
"r_content": "回復內容",
"grop": "如果沒有to_u_id的話就需要拿到上一層的grop_id+1",
"m_id": "文章id",
"u_id": "用戶id"
}
* @apiSuccessExample Response (example):
* HTTP/1.1 200
回復文章的里面別人的評論
{
"r_content": "回復內容44454",
"grop": 2,
"m_id": 2,
"u_id": 2,
"to_u_id":3
}
*/
/**
* @api {get} ([v1|v2]+)/reply/(\d+)$ [get]得到單篇文章的評論
* @apiName get_id_reply
* @apiGroup Get_reply
* @apiSuccessExample Response (example):
* HTTP/1.1 200
{
"id": "評論紀錄ID",
"to_u_id": "默認null,即為回復誰的id",
"to_u_id": {
"id": 2,
"u_user": "liu1"
},
"r_content": "回復內容3",
"r_c_time": "回復時間,默認null",
"grop": "評論樓id",
"m_id": "評論文id",
"u_id": "評論人id"
}
*/
/**
* @api {delete} ([v1|v2]+)/get/(\d+) [put]刪除單篇文章
* @apiName delete_fun
* @apiGroup Show One
*/
/**
* @api {put} ([v1|v2]+)/get/(\d+) [put]更新單篇文章
* @apiName update_fun
* @apiGroup Show One
* @apiSuccessExample Response (example):
* HTTP/1.1 200
{
"id": 1,
"t_type": "文章分類的id",
"u_id": "用戶名",
"m_head": "標題",
"m_content": "內容"
}
*/
/**
* @api {post} ([v1|v2]+)/get/(\d+) [post]推薦單篇文章
* @apiName post_fun
* @apiGroup Show One
* @apiSuccessExample Response (example):
* HTTP/1.1 200
{
"msg": "推薦成功",
"code": 10003
}
*/
/**
* @api {get} ([v1|v2]+)/get/(\d+) [get]單篇文章
* @apiName get_fun
* @apiGroup Show One
* @apiSuccess {Int} id 文章 ID.
* @apiSuccess {Int} u_id 作者名.
* @apiSuccess {Int} t_type 文章類型.
* @apiSuccess {String} m_head 文章標題.
* @apiSuccess {String} m_content 文章內容.
* @apiSuccess {Time} m_time 文章發表時間.
* @apiSuccess {String} m_image 附帶圖片.
* @apiSuccess {Int} y_dl 閱讀量.
* @apiSuccess {Int} t_jl 推薦量.
* @apiSuccessExample Response (example):
* HTTP/1.1 200
{
"id": 2,
"t_type": "傷感文",
"u_id": "liu1",
"m_head": "這是標題2",
"m_content": "內容",
"m_time": null,
"m_image": null,
"y_dl": 1,
"t_jl": 1
}
*/
/**
* @api {post} ([v1|v2]+)/get/ [post]提交文章
* @apiName post_fun
* @apiGroup Show
* @apiSuccess {Int} id 文章 ID.
* @apiSuccess {Int} u_id 作者ID.
* @apiSuccess {Int} t_type 文章類型ID.
* @apiSuccess {String} m_head 文章標題.
* @apiSuccess {String} m_content 文章內容.
* @apiSuccessExample Request (example):
* HTTP/1.1 200 Not Authenticated
{
"t_type": "1",
"u_id": "1",
"m_head": "這是標題1147",
"m_content": "內容147",
}
*/
/**
* @api {get} ([v1|v2]+)/get/ [get]獲取一頁的列表
* @apiName Get_list
* @apiGroup Show
* @apiSuccess {String} id 文章 ID.
* @apiSuccess {String} u_id 作者名.
* @apiSuccess {String} t_type 文章類型.
* @apiSuccess {String} m_head 文章標題.
* @apiSuccess {String} m_content 文章內容.
*/
/**
* @api {post} ([v1|v2]+)/auth/ 登錄 and 注冊
* @apiName Login&Regist
* @apiGroup User
* @apiParam {Number} username 唯一用戶 ID.
* @apiParam {Number} password 用戶密碼.
* @apiParam {Number} regist 注冊用戶時使用,有傳參數即代表注冊用戶.
* @apiSuccess {String} code 成功狀態碼.
* @apiSuccess {String} msg 成功信息.
* @apiSuccess {String} u_id 登錄用戶.
* @apiSuccess {String} token 登錄token_24小時有效.
*
* @apiError code 錯誤狀態碼.
* @apiError msg 錯誤信息.
*
* @apiSuccessExample Request (example):
* HTTP/1.1 200 Not Authenticated
* 登錄示例——#協議form-data {username=liu&password=xxx;}
* 注冊示例——#協議form-data {username=liu&password=xxx®ist=1;}
*/
