1.安装node.js https://nodejs.org/zh-cn/
2.cmd打开
node -v //版本查看
npm -v //版本查看
npm install apidoc -g //安装
3.apidoc.json 项目根目录新建
{
"name": "ServiceEbikeAPIs",
"version": "3.1.0",
"description": "车辆服务接口文档",
"title": "ServiceEbikeAPIs",
"url" : "http://cjl3.rokyinfo.net:7190/api-ebike"
}
4.demo
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/7/16
* Time: 15:21
*/
class Doc
{
/**
* @apiDefine test 用户模块
*/
/**
* @api {post} /User/Select 用户信息
* @apiName User
* @apiGroup test
*
* @apiParam {string} account 账号
* @apiParam {string} password 密码
*
* @apiSuccess {String} res1 返回值1
* @apiSuccessExample Success-Response:
* {
* res1:"test"
* }
*/
public function test()
{
}
/**
*
* @api {get} desk/Carpark/zcqList 早餐券管理
* @apiName zcqList
* @apiGroup test
*
* @apiHeader {String} authorization 用户授权token
* @apiHeaderExample {json} Header-Example:
* {
* "authorization": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOjM2NzgsImF1ZGllbmNlIjoid2ViIiwib3BlbkFJZCI6MTM2NywiY3JlYXRlZCI6MTUzMzg3OTM2ODA0Nywicm9sZXMiOiJVU0VSIiwiZXhwIjoxNTM0NDg0MTY4fQ.Gl5L-NpuwhjuPXFuhPax8ak5c64skjDTCBC64N_QdKQ2VT-zZeceuzXB9TqaYJuhkwNYEhrV3pUx1zhMWG7Org",
* }
* @apiParam {Number} page=1 页码
* @apiParam {Number} limit=30 每页数据量
* @apiParam {Number} dt 登录时间 0 全部 1当天 2昨天
* @apiParam {String} status 类型 0 全部 1发放 2回收 3废弃
* @apiParam {String} start_date 开始时间
* @apiParam {String} end_date 结束时间
* @apiParam {String} room_no 房号
* @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK
* {
* "isSuccess":true,
* "result":{
* "data":{},
* "count":6
* }
* }
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "isSuccess": false,
* "errCode":"",
* "errMsg":""
* }
*/
public function test1()
{
}
}
5.生成文档
apidoc -i Doc -o apidoc
6.注释规范
https://apidocjs.com/#demo