phpDoc使用

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值