apidoc操作

这篇博客介绍了如何使用apidoc来创建API文档。首先确保系统安装了Node.js,然后通过npm全局安装apidoc。接着初始化apidoc.json配置文件,并提供了示例注释来定义API组、参数和请求。示例中展示了用户登录API的详细说明,包括请求和响应示例,以及错误响应的处理。最后,执行apidoc命令生成文档。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

apidoc操作

apidoc


  1. 首先要确认你的系统安装了nodejs

  2. install apidoc

    npm install -g apidoc

  3. init apidoc.json

    {
    "name": "测试apidoc",   
    "version": "1.0.0",                
    "description": "接口测试",
    "title": "test apidoc",
    "url" : "http://localhost/test",
    "sampleUrl" : "http://localhost/test"
    }
    
  4. init java ref:http://apidocjs.com/#params
    /**

    • @apiDefine CentraServerGroup Centra-Server
      *用户登录 注册 等
      */

/**
* @apiDefine UserParam
* @apiParam {Number} reqType .
* @apiParam {String} sign .
* @apiParam {String} password User password.
*/

/**
* @api {post} /user/signin User sign in
* @apiName signIn
* @apiGroup CentraServerGroup
* @apiUse UserParam
* @apiParamExample {json} Request-Example:
{
“osType”: 0,
“password”: “99”,
“userId”: “99@qq.com”
}

  • @apiSuccess {String} firstname Firstname of the User.
  • @apiSuccess {String} lastname Lastname of the User.
    *
  • @apiSuccessExample Success-Response:
  • HTTP/1.1 200 OK
  • {
  • “firstname”: “John”,
  • “lastname”: “Doe”
  • }
    *
  • @apiErrorExample Error-Response:
    {
    “info”: {
    “message”: “Something went wrong with your Signin”
    },
    “code”: 0
    }
    */

5. execute
apidoc -i src/ -o apidoc/

[demo____________:)))address:][1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值