码迷,mamicode.com
首页 > Windows程序 > 详细

使用apidocJs快速生成在线文档

时间:2018-06-15 13:07:24      阅读:1920      评论:0      收藏:0      [点我收藏+]

标签:地址   creat   last   成功   示例   tip   bsp   token   rm -rf   

https://blog.csdn.net/xialei199023/article/details/63251482

 

https://blog.csdn.net/qq_16142851/article/details/78319768?locationNum=1&fps=1

 

对比下面的两个例子,对apidoc的文档参数就有个基本认识了

例子 01

/**
* @api {get} index.php?i=  测试一
* @apiGroup test
* @apiVersion 0.0.1
* @apiDescription 这是第一个测试
* @apiParam {String} token 登录token
* @apiParamExample 请求样例
* /index.php?i=8888
*  @apiSuccess {int} type 类型 0:上行 1:下行
* @apiExample 请求成功数据
* {
*    "status": "1",
*    "data": {
*               "first": 1,
*               "last": 3,
*    },
*    "msg": "操作成功"
* } 
* @apiExample {json} 失败返回样例:
*     {"code":"0","msg":"修改成功"}
*/

例子02

/**
    * @api {POST} /test/:id 测试二
    * @apiGroup test
    * @apiVersion 0.0.1
    * @apiDescription 这是第二个测试
    * @apiParam  {String} name 名字
    * @apiParam  {String} [phone] 手机
    * @apiSuccess (Success) {String} msg 信息
    * @apiSuccess (Success) {int} code 0 代表无错误 1代表有错误
    * @apiError (Error) {String} msg 信息
    * @apiError (Error) {String} m 信息
    * @apiParamExample 请求样例
    * /index.php?i=8888
    * @apiSuccessExample {json} 返回样例
    *                {"code":"0","msg":"修改成功"}
    * @apiErrorExample {json} 失败返回样例
    *                {"code":"0","msg":"修改成功"}
*/

apidoc 文档参数详细说明

* @apiDeprecated [提示消息] //弃用标志 如果未指定[]里面内容{包括中括号},则下次不产生该接口,如果指定,则输出提示消息
* @api {POST} /test/:id 测试二 //指定接收方式以及显示名称
* @apiGroup //分组
* @apiVersion //版本
* @apiDescription //描述
* @apiParam  {String} name 名字 // 参数类型 以及参数名称 没有中括号代表必选参数
* @apiParam  {String} [phone] 手机 // 参数类型 以及参数名称 [phone] 代表可选参数
* @apiSuccess (Success) {String} msg 信息 //返回成功数据名称以及类型
* @apiError (Error) {String} msg 信息 //返回失败数据名称以及类型
* @apiParamExample 请求样例  //示例
* /index.php?i=8888        //例子
* @apiSuccessExample {json} 返回样例  // 返回成功数据以及指定返回数据格式
*                {"code":"0","msg":"修改成功"} //指定json格式后可以不用格式化,apidoc 输出的时候会做做处理
* @apiErrorExample {json} 失败返回样例 // 返回失败数据以及指定返回数据格式
*                {"code":"0","msg":"修改成功"}

tips

01: warn: Please create an apidoc.json configuration file.

检查你的项目下 有没有 apidoc.json  //没有则创建
{
  "name": "文档名称",
  "version": "0.1.0", //版本号
  "description": "apiDoc basic example", // 描述
  "title": "Custom apiDoc browser title", // 头部
  "url" : "http://192.168.197.135/"  // 项目地址
  "sampleUrl" : "http://192.168.197.135/"  //接口默认发送的地址
}

02:warn: parser plugin ‘param’ not found in block: 1

具体问题没有找到 下面的是我的做法
# rm -rf test/apidoc/*
# apidoc -i test/ -o test/apidoc/
-- 这样子就解决了!

03 :apidoc error: No files found. { Path: ‘/data/wwwroot’ }

应该是因为 nodejs版本太高 以及 npn版本太高的原因

使用apidocJs快速生成在线文档

标签:地址   creat   last   成功   示例   tip   bsp   token   rm -rf   

原文地址:https://www.cnblogs.com/mapu/p/9186282.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!