一、APIDOC
(1)官网:http://apidocjs.com/
(2)页面简单
二、使用:
①安装nodejs。然后npm install apidoc -g
②在自己的项目下新建一个json文件名为:apidoc.json
{
"name": "APIDOC测试",
"version": "1.0.0",
"description": "测试接口文档",
"title": "APIDOC测试",
"url" : "http://localhost:8080/api-ebike"
}
③代码案例:
@RestController("/users")
public class TestController {
/**
* @api {POST} /test/getById 根据id查询用户
* @apiGroup Users
* @apiVersion 1.1.0
* @apiDescription 根据id查询用户
* @apiHeader {String} Authorization 用户授权token
* @apiHeader {String} firm 厂商编码
* @apiHeaderExample {json} Header-Example:
* {
* "Authorization": "elkjlkjvcxncsdfkjlsdkjf,smdnf,mn",
* "firm": "cnE="
* }
* @apiParam {Integer} id userId[必填]
* @apiSuccess {String} status 信息
* @apiSuccess {String} msg 返回码
* @apiSuccess {String} data 数据
* @apiSuccessExample {json} 成功返回样例:
* {
* "status": 0,
* "msg": "success",
* "data": {
* "id": 1,
* "appName": "1",
* "appId": null,
* "appSecret": "1",
* "isFlag": "1",
* "accessToken": "1"
* }
* }
* @apiErrorExample {json} 错误返回样例:
* {"respCode":"F2001","respMessage":"验证码有误,请重试"}
* {"respCode":"F2003","respMessage":"手机验证码有误,请确认后重试"}
* {"respCode":"F2004","respMessage":"邮箱验证码有误,请确认后重试"}
* {"respCode":"F9999","respMessage":"系统异常提示"}
*/
@RequestMapping("/getById")
public ServerResponse<AppEntity> getById(Integer id){
AppEntity entity = new AppEntity();
entity.setId(id);
entity.setAccessToken("1");
entity.setAppName("1");
entity.setAppSecret("1");
entity.setIsFlag("1");
return ServerResponse.createBySuccess("success", entity);
}
}
④在项目目录下也就是apidoc.json同级目录下执行:
apidoc -i src/ -o apidoc/
⑤ 然后在apidoc这个目录下,打开index.html。就可以查看。