Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev

This commit is contained in:
suxiaoxin 2018-02-28 16:09:27 +08:00
commit bc9aa15db0
43 changed files with 889 additions and 455 deletions

View File

@ -11,7 +11,7 @@
#### Bug Fixed
* 将部分数据拷贝变成使用immer
* 修复测试集合table拖动频繁请求的问题
### v1.3.6

View File

@ -141,7 +141,7 @@ class MethodsList extends Component {
const { list, moreFlag } = this.state;
const { click, clickValue, clickIndex, params } = this.props;
let showList = moreFlag ? list.slice(0, 4) : list;
console.log('clickValue', clickValue)
return (
<div className="modal-postman-form-method">

View File

@ -217,8 +217,6 @@ class ModalPostman extends Component {
return '{{ ' + str + ' }}'
}
console.log('methodsParamsList',methodsParamsList);
return (
<Modal
title={<p><Icon type="edit" /> 高级参数设置</p>}

View File

@ -6,8 +6,6 @@ import AceEditor from 'client/components/AceEditor/AceEditor'
import _ from 'underscore'
import { isJson, deepCopyJson } from '../../common.js'
import ModalPostman from '../ModalPostman/index.js'
import CheckCrossInstall, { initCrossRequest } from './CheckCrossInstall.js'
import './Postman.scss';

View File

@ -343,7 +343,6 @@ class InterfaceColContent extends Component {
}
onDrop =() =>{
console.log(1111);
let changes = [];
this.state.rows.forEach((item, index) => {
changes.push({

View File

@ -31,7 +31,6 @@ class ProjectToken extends Component {
}
async componentDidMount() {
console.log(this.props.curProjectRole);
await this.props.getToken(this.props.projectId);
}

BIN
doc/images/baseSet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
doc/images/getQuery.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
doc/images/requestSet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -42,6 +42,8 @@ npm run install-server //安装程序会初始化数据库索引和管理员账
node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候
```
可以参考插件Wiki里面的<a href="./plugin.html">二次开发文档</a>
## 服务器管理
推荐使用 pm2 管理 node 服务器启动,停止,具体使用方法可参考下面的教程:

View File

@ -7,18 +7,34 @@
[新建接口](./quickstart.html#新建接口) 后,点击新添加的接口,右侧可以看到接口的预览信息,点击右侧的 `编辑` Tab项进入编辑面板。
面板中你可以看到接口的基本信息(接口名称、分类、路径),除此以外,你还可以完善以下接口信息:
面板中你可以看到接口的基本信息(接口名称、分类、路径),除此以外,你还可以完善以下接口信息:
- Path: 接口路径,支持 restful 动态路由,例如 /api/:id, id是动态参数
- 状态: 用于标识接口是否开发完成。
### 基本设置
- 接口路径:可以更改 HTTP 请求方式,并且支持 restful 动态路由,例如 /api/:id/{name}, id和name是动态参数
- 选择分类:可以更改接口所在分类
- 状态:用于标识接口是否开发完成。
<img src="./images/baseSet.png" />
### Request 设置
- Query参数 接口 url 的查询字符串点击『添加Query参数』按钮来添加参数可以通过拖动来交换参数位置
- 请求Bodyhttp 请求 body 部分如果http请求方式是 post, put 等请求方式时会有 req_body 部分。req_body_type 形式有4种分别是 form, json, file 和 raw 。
- Headers: http 请求头字段,在 req_body 形式是 form 格式下会在 header 中自动生成 'Content-Type application/x-www-form-urlencoded'其他3种格式也会自动生成不同 header
<img src="./images/requestSet.png" />
### Response 设置
- 响应 Body: 模拟返回结果, 分为 `json` & `raw` 两种形式。基于 mockjs (具体使用方法详见<a href="./mock.html">Mock 介绍</a>)和 json5使用注释方式写参数说明。 为了方便数据编写可以按F9来使用全局编辑
### 备注 & 其他
- 接口描述: 用简短的文字描述接口的作用。
- query: 接口url的查询字符串。
- 请求 Headers: http 请求头字段。
- 请求 Body: http 请求 body 部分。
- 响应 Body: 模拟返回结果。
> 响应 Body 分为 `json` & `raw` 两种形式
- 邮件通知:开启后将此次接口的改动以邮件的形式发送至项目组所有成员和关注该项目的成员(邮件默认情况下自动开启)
- 开放接口:默认为关闭状态,用户可以在 数据导出 时选择只导出公开接口
- 是否开启邮件通知:开启后将此次接口的改动以邮件的形式发送至项目组所有成员(邮件默认情况下自动开启)。
## 接口运行
接口运行功能是用来测试真实接口的类似『Postman』的功能。
@ -26,8 +42,7 @@
点击运行 tab ,可进入到接口测试页面,首先安装『chrome crossRequest』扩展才可正常使用此功能。点击保存按钮可把当前接口保存到测试集方便下次调试。
> 安装完插件记得刷新页面
<img src="./images/interface_run.jpg" />
<img src="./images/interface_run.png" />

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -147,15 +142,15 @@
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#Mock_期望">Mock 期望</a>
<a href="#Mock 期望">Mock 期望</a>
</li>
<li >
<a href="#自定义_Mock_脚本">自定义 Mock 脚本</a>
<a href="#自定义 Mock 脚本">自定义 Mock 脚本</a>
</li>
<li >
<a href="#Mock_优先级说明">Mock 优先级说明</a>
<a href="#Mock 优先级说明">Mock 优先级说明</a>
</li>
</ul>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 </title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -266,6 +261,14 @@
<a href="#-project-up_env">/project/up_env</a>
</li>
<li >
<a href="#-project-token">/project/token</a>
</li>
<li >
<a href="#-project-update_token">/project/update_token</a>
</li>
<li >
<a href="#-project-search">/project/search</a>
</li>
@ -344,6 +347,14 @@
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#-interface-up_index">/interface/up_index</a>
</li>
<li >
<a href="#-interface-up_cat_index">/interface/up_cat_index</a>
</li>
<li >
<a href="#-col-list">/col/list</a>
</li>
@ -376,6 +387,10 @@
<a href="#-col-up_col">/col/up_col</a>
</li>
<li >
<a href="#-col-up_case_index">/col/up_case_index</a>
</li>
<li >
<a href="#-col-up_col_index">/col/up_col_index</a>
</li>
@ -2107,7 +2122,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#110" target="_blank">./server/controllers/project.js:110</a>
<a href="./static/server/controllers/project.js.html#119" target="_blank">./server/controllers/project.js:119</a>
</p>
@ -2248,7 +2263,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#199" target="_blank">./server/controllers/project.js:199</a>
<a href="./static/server/controllers/project.js.html#212" target="_blank">./server/controllers/project.js:212</a>
</p>
@ -2332,7 +2347,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#256" target="_blank">./server/controllers/project.js:256</a>
<a href="./static/server/controllers/project.js.html#269" target="_blank">./server/controllers/project.js:269</a>
</p>
@ -2416,7 +2431,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#311" target="_blank">./server/controllers/project.js:311</a>
<a href="./static/server/controllers/project.js.html#324" target="_blank">./server/controllers/project.js:324</a>
</p>
@ -2494,7 +2509,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#333" target="_blank">./server/controllers/project.js:333</a>
<a href="./static/server/controllers/project.js.html#346" target="_blank">./server/controllers/project.js:346</a>
</p>
@ -2577,7 +2592,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#366" target="_blank">./server/controllers/project.js:366</a>
<a href="./static/server/controllers/project.js.html#379" target="_blank">./server/controllers/project.js:379</a>
</p>
@ -2793,7 +2808,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#425" target="_blank">./server/controllers/project.js:425</a>
<a href="./static/server/controllers/project.js.html#438" target="_blank">./server/controllers/project.js:438</a>
</p>
@ -2865,7 +2880,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#455" target="_blank">./server/controllers/project.js:455</a>
<a href="./static/server/controllers/project.js.html#468" target="_blank">./server/controllers/project.js:468</a>
</p>
@ -2951,7 +2966,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#502" target="_blank">./server/controllers/project.js:502</a>
<a href="./static/server/controllers/project.js.html#515" target="_blank">./server/controllers/project.js:515</a>
</p>
@ -3040,7 +3055,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#547" target="_blank">./server/controllers/project.js:547</a>
<a href="./static/server/controllers/project.js.html#560" target="_blank">./server/controllers/project.js:560</a>
</p>
@ -3158,7 +3173,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#636" target="_blank">./server/controllers/project.js:636</a>
<a href="./static/server/controllers/project.js.html#649" target="_blank">./server/controllers/project.js:649</a>
</p>
@ -3240,6 +3255,154 @@
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-project-token" class="page-header subject">
/project/token
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-project-token">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取token数据
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#710" target="_blank">./server/controllers/project.js:710</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id</td>
<td>Number</td>
<td>项目id不能为空</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>q</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-project-update_token" class="page-header subject">
/project/update_token
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-project-update_token">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新token数据
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#739" target="_blank">./server/controllers/project.js:739</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id</td>
<td>Number</td>
<td>项目id不能为空</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>q</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
@ -3260,7 +3423,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#697" target="_blank">./server/controllers/project.js:697</a>
<a href="./static/server/controllers/project.js.html#771" target="_blank">./server/controllers/project.js:771</a>
</p>
@ -3358,7 +3521,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#103" target="_blank">./server/controllers/interface.js:103</a>
<a href="./static/server/controllers/interface.js.html#117" target="_blank">./server/controllers/interface.js:117</a>
</p>
@ -3679,7 +3842,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#203" target="_blank">./server/controllers/interface.js:203</a>
<a href="./static/server/controllers/interface.js.html#216" target="_blank">./server/controllers/interface.js:216</a>
</p>
@ -3927,7 +4090,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#277" target="_blank">./server/controllers/interface.js:277</a>
<a href="./static/server/controllers/interface.js.html#290" target="_blank">./server/controllers/interface.js:290</a>
</p>
@ -3992,7 +4155,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#318" target="_blank">./server/controllers/interface.js:318</a>
<a href="./static/server/controllers/interface.js.html#331" target="_blank">./server/controllers/interface.js:331</a>
</p>
@ -4029,6 +4192,30 @@
<td></td>
</tr>
<tr>
<td>page</td>
<td>Number</td>
<td>当前页</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>limit</td>
<td>Number</td>
<td>每一页限制条数</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
@ -4057,7 +4244,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#416" target="_blank">./server/controllers/interface.js:416</a>
<a href="./static/server/controllers/interface.js.html#462" target="_blank">./server/controllers/interface.js:462</a>
</p>
@ -4290,7 +4477,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#576" target="_blank">./server/controllers/interface.js:576</a>
<a href="./static/server/controllers/interface.js.html#622" target="_blank">./server/controllers/interface.js:622</a>
</p>
@ -4362,7 +4549,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#774" target="_blank">./server/controllers/interface.js:774</a>
<a href="./static/server/controllers/interface.js.html#820" target="_blank">./server/controllers/interface.js:820</a>
</p>
@ -4427,7 +4614,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#806" target="_blank">./server/controllers/interface.js:806</a>
<a href="./static/server/controllers/interface.js.html#852" target="_blank">./server/controllers/interface.js:852</a>
</p>
@ -4704,6 +4891,126 @@
<h2 id="col" class="page-header subject">col<a class="hashlink" href="#col">#</a></h2>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-interface-up_index" class="page-header subject">
/interface/up_index
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-interface-up_index">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新多个接口case index
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#949" target="_blank">./server/controllers/interface.js:949</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id, index</td>
<td>Array</td>
<td></td>
<td>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-interface-up_cat_index" class="page-header subject">
/interface/up_cat_index
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-interface-up_cat_index">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新多个接口cat index
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interface.js.html#981" target="_blank">./server/controllers/interface.js:981</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id, index</td>
<td>Array</td>
<td></td>
<td>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-list" class="page-header subject">
@ -4784,7 +5091,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#52" target="_blank">./server/controllers/interfaceCol.js:52</a>
<a href="./static/server/controllers/interfaceCol.js.html#56" target="_blank">./server/controllers/interfaceCol.js:56</a>
</p>
@ -4865,12 +5172,12 @@
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取一个接口集下的所有的接口用例
获取一个接口集下的所有的测试用例
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#110" target="_blank">./server/controllers/interfaceCol.js:110</a>
<a href="./static/server/controllers/interfaceCol.js.html#114" target="_blank">./server/controllers/interfaceCol.js:114</a>
</p>
@ -4927,12 +5234,12 @@
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取一个接口集下的所有的接口用例
获取一个接口集下的所有的测试用例
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#178" target="_blank">./server/controllers/interfaceCol.js:178</a>
<a href="./static/server/controllers/interfaceCol.js.html#156" target="_blank">./server/controllers/interfaceCol.js:156</a>
</p>
@ -4989,12 +5296,12 @@
</blockquote>
<p>
<small class="text-muted">描述:</small>
增加一个接口用例
增加一个测试用例
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#239" target="_blank">./server/controllers/interfaceCol.js:239</a>
<a href="./static/server/controllers/interfaceCol.js.html#217" target="_blank">./server/controllers/interfaceCol.js:217</a>
</p>
@ -5171,12 +5478,12 @@
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新一个接口用例
更新一个测试用例
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#487" target="_blank">./server/controllers/interfaceCol.js:487</a>
<a href="./static/server/controllers/interfaceCol.js.html#465" target="_blank">./server/controllers/interfaceCol.js:465</a>
</p>
@ -5341,12 +5648,12 @@
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取一个接口用例详情
获取一个测试用例详情
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#551" target="_blank">./server/controllers/interfaceCol.js:551</a>
<a href="./static/server/controllers/interfaceCol.js.html#529" target="_blank">./server/controllers/interfaceCol.js:529</a>
</p>
@ -5408,7 +5715,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#618" target="_blank">./server/controllers/interfaceCol.js:618</a>
<a href="./static/server/controllers/interfaceCol.js.html#572" target="_blank">./server/controllers/interfaceCol.js:572</a>
</p>
@ -5462,6 +5769,66 @@
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-up_case_index" class="page-header subject">
/col/up_case_index
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-col-up_case_index">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新多个接口case index
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#616" target="_blank">./server/controllers/interfaceCol.js:616</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id, index</td>
<td>Array</td>
<td></td>
<td>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
@ -5477,12 +5844,12 @@
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新多个接口case index
更新多个测试集合 index
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#662" target="_blank">./server/controllers/interfaceCol.js:662</a>
<a href="./static/server/controllers/interfaceCol.js.html#649" target="_blank">./server/controllers/interfaceCol.js:649</a>
</p>
@ -5542,7 +5909,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#694" target="_blank">./server/controllers/interfaceCol.js:694</a>
<a href="./static/server/controllers/interfaceCol.js.html#682" target="_blank">./server/controllers/interfaceCol.js:682</a>
</p>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -163,15 +158,15 @@
</li>
<li >
<a href="#Postman_数据导入">Postman 数据导入</a>
<a href="#Postman 数据导入">Postman 数据导入</a>
</li>
<li >
<a href="#HAR_数据导入">HAR 数据导入</a>
<a href="#HAR 数据导入">HAR 数据导入</a>
</li>
<li >
<a href="#Swagger_数据导入">Swagger 数据导入</a>
<a href="#Swagger 数据导入">Swagger 数据导入</a>
</li>
</ul>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 内网部署</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -117,11 +112,11 @@
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#方式一._可视化部署[推荐]">方式一. 可视化部署[推荐]</a>
<a href="#方式一. 可视化部署[推荐]">方式一. 可视化部署[推荐]</a>
</li>
<li >
<a href="#方式二._命令行部署">方式二. 命令行部署</a>
<a href="#方式二. 命令行部署">方式二. 命令行部署</a>
</li>
</ul>
@ -141,7 +136,7 @@
<!-- <li > -->
<li >
<a href="#配置邮箱__仅支持_SMTP_">配置邮箱 (仅支持 SMTP)</a>
<a href="#配置邮箱 (仅支持 SMTP)">配置邮箱 (仅支持 SMTP)</a>
</li>
<!-- <li > -->
@ -179,7 +174,8 @@ cd vendors
npm install --production --registry https<span class="token operator">:</span>//registry.npm.taobao.org
npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置
node server/app.js //启动服务器后,请访问 <span class="token number">127.0</span>.<span class="token number">0.1</span><span class="token operator">:</span><span class="token punctuation">{</span>config.json配置的端口<span class="token punctuation">}</span>,初次运行会有个编译的过程,请耐心等候
</code></pre><h2 class="subject" id="服务器管理">服务器管理 <a class="hashlink" href="#服务器管理">#</a></h2><p>推荐使用 pm2 管理 node 服务器启动,停止,具体使用方法可参考下面的教程:</p>
</code></pre><p>可以参考插件Wiki里面的<a href="./plugin.html">二次开发文档</a></p>
<h2 class="subject" id="服务器管理">服务器管理 <a class="hashlink" href="#服务器管理">#</a></h2><p>推荐使用 pm2 管理 node 服务器启动,停止,具体使用方法可参考下面的教程:</p>
<ul>
<li><a href="http://pm2.keymetrics.io/docs/usage/quick-start/">官网文档</a></li><li><a href="http://imweb.io/topic/57c8cbb27f226f687b365636">PM2实用入门指南</a> </li></ul>
<h2 class="subject" id="升级">升级 <a class="hashlink" href="#升级">#</a></h2><p>升级项目版本是非常容易的,并且不会影响已有的项目数据,只会同步 vendors 目录下的源码文件。</p>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 </title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -106,7 +101,7 @@
<p class="home-version">当前版本v1.3.5</p>
<p class="home-version">当前版本v1.3.6</p>
</div>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -178,20 +173,23 @@
<ul>
<li><code>接口集合</code> 将接口进行分类,使结构结构更清晰,一个接口只能属于一个集合,且不允许与其他接口重名。</li><li><code>测试集合</code> 为了方便我们测试接口,<code>测试集合</code> 将若干接口组合在一起,在这里一个接口可以属于不同集合。</li></ul>
<h2 class="subject" id="接口配置">接口配置 <a class="hashlink" href="#接口配置">#</a></h2><p><a href="./quickstart.html#新建接口">新建接口</a> 后,点击新添加的接口,右侧可以看到接口的预览信息,点击右侧的 <code>编辑</code> Tab项进入编辑面板。</p>
<p>在改面板中你可以看到接口的基本信息(接口名称、分类、路径),除此以外,你还可以完善以下接口信息:</p>
<ul>
<li>Path: 接口路径,支持 restful 动态路由,例如 /api/:id, id是动态参数</li><li>状态: 用于标识接口是否开发完成。</li><li>接口描述: 用简短的文字描述接口的作用。</li><li>query: 接口url的查询字符串。</li><li>请求 Headers: http 请求头字段。</li><li>请求 Body: http 请求 body 部分。</li><li><p>响应 Body: 模拟返回结果。</p>
<blockquote>
<p>响应 Body 分为 <code>json</code> &amp; <code>raw</code> 两种形式</p>
</blockquote>
</li><li><p>是否开启邮件通知:开启后将此次接口的改动以邮件的形式发送至项目组所有成员(邮件默认情况下自动开启)。</p>
</li></ul>
<p>在该面板中你可以看到接口的基本信息(接口名称、分类、路径),除此以外,你还可以完善以下接口信息:</p>
<h3 class="subject" id="基本设置">基本设置 <a class="hashlink" href="#基本设置">#</a></h3><ul>
<li>接口路径:可以更改 HTTP 请求方式,并且支持 restful 动态路由,例如 /api/:id/{name}, id和name是动态参数</li><li>选择分类:可以更改接口所在分类</li><li>状态:用于标识接口是否开发完成。</li></ul>
<p><img src="./images/baseSet.png" /></p>
<h3 class="subject" id="Request_设置">Request 设置 <a class="hashlink" href="#Request_设置">#</a></h3><ul>
<li>Query参数 接口 url 的查询字符串点击『添加Query参数』按钮来添加参数可以通过拖动来交换参数位置</li><li>请求Bodyhttp 请求 body 部分如果http请求方式是 post, put 等请求方式时会有 req_body 部分。req_body_type 形式有4种分别是 form, json, file 和 raw 。</li><li>Headers: http 请求头字段,在 req_body 形式是 form 格式下会在 header 中自动生成 &#39;Content-Type application/x-www-form-urlencoded&#39;其他3种格式也会自动生成不同 header</li></ul>
<p><img src="./images/requestSet.png" /></p>
<h3 class="subject" id="Response_设置">Response 设置 <a class="hashlink" href="#Response_设置">#</a></h3><ul>
<li>响应 Body: 模拟返回结果, 分为 <code>json</code> &amp; <code>raw</code> 两种形式。基于 mockjs (具体使用方法详见<a href="./mock.html">Mock 介绍</a>)和 json5使用注释方式写参数说明。 为了方便数据编写可以按F9来使用全局编辑</li></ul>
<h3 class="subject" id="备注_&amp;_其他">备注 &amp; 其他 <a class="hashlink" href="#备注_&amp;_其他">#</a></h3><ul>
<li>接口描述: 用简短的文字描述接口的作用。</li><li>邮件通知:开启后将此次接口的改动以邮件的形式发送至项目组所有成员和关注该项目的成员(邮件默认情况下自动开启)</li><li>开放接口:默认为关闭状态,用户可以在 数据导出 时选择只导出公开接口</li></ul>
<h2 class="subject" id="接口运行">接口运行 <a class="hashlink" href="#接口运行">#</a></h2><p>接口运行功能是用来测试真实接口的类似『Postman』的功能。</p>
<p>点击运行 tab ,可进入到接口测试页面,首先安装『chrome crossRequest』扩展才可正常使用此功能。点击保存按钮可把当前接口保存到测试集方便下次调试。</p>
<blockquote>
<p>安装完插件记得刷新页面</p>
</blockquote>
<p><img src="./images/interface_run.jpg" /></p>
<p><img src="./images/interface_run.png" /></p>
</div>
</div>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -145,19 +140,19 @@
</li>
<li >
<a href="#定义_mock_数据示例">定义 mock 数据示例</a>
<a href="#定义 mock 数据示例">定义 mock 数据示例</a>
</li>
<li >
<a href="#YApi-Mock_跟_Mockjs_区别">YApi-Mock 跟 Mockjs 区别</a>
<a href="#YApi-Mock 跟 Mockjs 区别">YApi-Mock 跟 Mockjs 区别</a>
</li>
<li >
<a href="#如何使用_Mock">如何使用 Mock</a>
<a href="#如何使用 Mock">如何使用 Mock</a>
</li>
<li >
<a href="#Mock_语法规范">Mock 语法规范</a>
<a href="#Mock 语法规范">Mock 语法规范</a>
</li>
</ul>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 插件 Wiki</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -135,7 +130,7 @@
</li>
<li >
<a href="#index.js_配置说明">index.js 配置说明</a>
<a href="#index.js 配置说明">index.js 配置说明</a>
</li>
<li >

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 插件 Wiki</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -129,11 +124,11 @@
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#后端_hookList">后端 hookList</a>
<a href="#后端 hookList">后端 hookList</a>
</li>
<li >
<a href="#前端_hookList">前端 hookList</a>
<a href="#前端 hookList">前端 hookList</a>
</li>
</ul>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 插件 Wiki</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 插件 Wiki</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 插件 Wiki</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 常见问题</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -105,37 +100,37 @@
<!-- <li > -->
<li >
<a href="#Q1_怎样联系组长?">Q1 怎样联系组长?</a>
<a href="#Q1 怎样联系组长?">Q1 怎样联系组长?</a>
</li>
<!-- <li > -->
<li >
<a href="#Q2_怎么快速迁移旧项目?">Q2 怎么快速迁移旧项目?</a>
<a href="#Q2 怎么快速迁移旧项目?">Q2 怎么快速迁移旧项目?</a>
</li>
<!-- <li > -->
<li >
<a href="#Q3_忘记密码怎么办?">Q3 忘记密码怎么办?</a>
<a href="#Q3 忘记密码怎么办?">Q3 忘记密码怎么办?</a>
</li>
<!-- <li > -->
<li >
<a href="#Q4_发现了_Bug_怎么办?">Q4 发现了 Bug 怎么办?</a>
<a href="#Q4 发现了 Bug 怎么办?">Q4 发现了 Bug 怎么办?</a>
</li>
<!-- <li > -->
<li >
<a href="#Q5_可视化部署一直处于_github_压缩包下载状态怎么办?">Q5 可视化部署一直处于 github 压缩包下载状态怎么办?</a>
<a href="#Q5 可视化部署一直处于 github 压缩包下载状态怎么办?">Q5 可视化部署一直处于 github 压缩包下载状态怎么办?</a>
</li>
<!-- <li > -->
<li >
<a href="#Q6_部署YApi遇到的问题">Q6 部署YApi遇到的问题</a>
<a href="#Q6 部署YApi遇到的问题">Q6 部署YApi遇到的问题</a>
</li>
</ul>

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 插件 Wiki</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 版本记录</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">
@ -102,6 +97,14 @@
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
<ul class="nav docs-sidenav">
<li >
<a href="#v1.3.7">v1.3.7</a>
</li>
<li >
<a href="#v1.3.6">v1.3.6</a>
</li>
<li >
<a href="#v1.3.5">v1.3.5</a>
</li>
@ -182,7 +185,15 @@
<div class="content-right markdown-body use-sidebar" role="main">
<h3 class="subject" id="v1.3.5">v1.3.5 <a class="hashlink" href="#v1.3.5">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
<h3 class="subject" id="v1.3.7">v1.3.7 <a class="hashlink" href="#v1.3.7">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
<li>增加测试集合列表的拖动功能</li><li>interfaceList页实现数据分页</li><li>新建接口的时候产生一个demo response</li><li>接口列表中增加“开放接口”状态</li><li>接口列表树形组件支持拖动</li></ul>
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
<li>将部分数据拷贝变成使用immer</li><li>修复测试集合table拖动频繁请求的问题</li></ul>
<h3 class="subject" id="v1.3.6">v1.3.6 <a class="hashlink" href="#v1.3.6">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
<li>增加服务端的自动化测试功能,可集成到 jenkins, github 做接口自动化测试</li><li>增加导出公共接口功能</li><li>增加复制接口路径按钮</li><li>增加项目 token 功能,可通过 token 访问开放接口</li><li>antd升级到v3</li></ul>
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
<li>修复接口动态提示有误</li><li>修复变量表达式无法反向展示的问题</li></ul>
<h3 class="subject" id="v1.3.5">v1.3.5 <a class="hashlink" href="#v1.3.5">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
<li>增加项目成员批量导入</li><li>数据导入同步数据导入支持swagger 3.0</li><li>swagger 数据导入支持 2xx 的httpcode</li><li>新增系统信息页面</li></ul>
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
<li>修复离开接口编辑页面的 confirm 框有时候会触发两次 &amp; confirm 的 X 按钮无效</li><li>修复添加集合后测试集合list不更新问题</li><li>测试集合点击对应接口侧边栏不切换</li><li>测试集合处,点击删除不成功</li><li>修改编辑接口后,再回到测试集合处数据不更新问题</li><li>修复mongodb帐号密码配置错误时引发的错误</li><li>修复删除分组后侧边数据没有更新问题</li></ul>

View File

@ -55,8 +55,11 @@ class baseController {
'/api/user/avatar',
'/api/user/login_by_ldap'
];
let openApiRouter = /^\/api\/open\/.*/
if (ignoreRouter.indexOf(ctx.path) > -1) {
this.$auth = true;
} else if(openApiRouter.test(ctx.path)){
this.$auth = true;
} else {
await this.checkLogin(ctx);
}

View File

@ -42,6 +42,19 @@ const showDiffMsg = require('../../common/diff-view.js');
const fs = require('fs-extra')
const path = require('path');
const RES_BODY_TPL= `
/**
* 这是一个 response 事例
*/
{
"errcode": 0, //错误编码
"data": {
"id": "uuid-xxx", //产品id
"name": "iphone" //产品名称
}
}
`
// const annotatedCss = require("jsondiffpatch/public/formatters-styles/annotated.css");
// const htmlCss = require("jsondiffpatch/public/formatters-styles/html.css");
@ -96,7 +109,8 @@ class interfaceController extends baseController {
'req_body_other': 'string',
res_body_type: 'string',
res_body: 'string',
custom_field_value: 'string'
custom_field_value: 'string',
'api_opened': 'boolean'
}
this.schemaMap = {
@ -159,7 +173,6 @@ class interfaceController extends baseController {
async add(ctx) {
let params = ctx.params;
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
if (!auth) {
return ctx.body = yapi.commons.resReturn(null, 40033, '没有权限');
@ -168,7 +181,7 @@ class interfaceController extends baseController {
params.method = params.method.toUpperCase();
params.req_params = params.req_params || [];
params.res_body_type = params.res_body_type ? params.res_body_type.toLowerCase() : 'json';
params.res_body = _.isUndefined(params.res_body) ? RES_BODY_TPL : params.res_body;
let http_path = url.parse(params.path, true);
if (!yapi.commons.verifyPath(http_path.pathname)) {
@ -350,11 +363,15 @@ class interfaceController extends baseController {
* @category interface
* @foldnumber 10
* @param {Number} project_id 项目id不能为空
* @param {Number} page 当前页
* @param {Number} limit 每一页限制条数
* @returns {Object}
* @example ./api/interface/list.json
*/
async list(ctx) {
let project_id = ctx.request.query.project_id;
let page = ctx.request.query.page || 1,
limit = ctx.request.query.limit || 10;
let project = await this.projectModel.getBaseInfo(project_id);
if (!project) {
return ctx.body = yapi.commons.resReturn(null, 407, '不存在的项目');
@ -369,8 +386,20 @@ class interfaceController extends baseController {
}
try {
let result = await this.Model.list(project_id);
ctx.body = yapi.commons.resReturn(result);
let result
if(limit === 'all'){
result = await this.Model.list(project_id);
} else{
result = await this.Model.listWithPage(project_id, page, limit);
}
let count = await this.Model.listCount({project_id});
ctx.body = yapi.commons.resReturn({
count: count,
total: Math.ceil(count / limit),
list: result
});
yapi.emitHook('interface_list', project_id).then();
} catch (err) {
ctx.body = yapi.commons.resReturn(null, 402, err.message);
@ -386,23 +415,35 @@ class interfaceController extends baseController {
}
async listByCat(ctx) {
let catid = ctx.request.query.catid;
let page = ctx.request.query.page || 1,
limit = ctx.request.query.limit || 10;
if (!catid) {
return ctx.body = yapi.commons.resReturn(null, 400, 'catid不能为空');
}
try {
let catdata = await this.catModel.get(catid);
let project = await this.projectModel.getBaseInfo(catdata.project_id);
if (project.project_type === 'private') {
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
}
}
let result = await this.Model.listByCatid(catid)
let result = await this.Model.listByCatidWithPage(catid, page, limit)
ctx.body = yapi.commons.resReturn(result);
let count = await this.Model.listCount({catid});
ctx.body = yapi.commons.resReturn({
count: count,
total: Math.ceil(count / limit),
list: result
});
} catch (err) {
ctx.body = yapi.commons.resReturn(null, 402, err.message);
ctx.body = yapi.commons.resReturn(null, 402, err.message+'1');
}
}
@ -431,6 +472,11 @@ class interfaceController extends baseController {
for (let j = 0; j < list.length; j++) {
list[j] = list[j].toObject()
}
list = list.sort((a, b) => {
return a.index - b.index;
});
item.list = list;
newResult[i] = item
}
@ -928,6 +974,70 @@ class interfaceController extends baseController {
})
}
/**
* 更新多个接口case index
* @interface /interface/up_index
* @method POST
* @category col
* @foldnumber 10
* @param {Array} [id, index]
* @returns {Object}
* @example
*/
async upIndex(ctx) {
try {
let params = ctx.request.body;
if (!params || !Array.isArray(params)) {
ctx.body = yapi.commons.resReturn(null, 400, "请求参数必须是数组")
}
params.forEach((item) => {
if (item.id) {
this.Model.upIndex(item.id, item.index).then((res) => { }, (err) => {
yapi.commons.log(err.message, 'error')
})
}
});
return ctx.body = yapi.commons.resReturn('成功!')
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
}
/**
* 更新多个接口cat index
* @interface /interface/up_cat_index
* @method POST
* @category col
* @foldnumber 10
* @param {Array} [id, index]
* @returns {Object}
* @example
*/
async upCatIndex(ctx) {
try {
let params = ctx.request.body;
if (!params || !Array.isArray(params)) {
ctx.body = yapi.commons.resReturn(null, 400, "请求参数必须是数组")
}
params.forEach((item) => {
if (item.id) {
this.catModel.upCatIndex(item.id, item.index).then((res) => { }, (err) => {
yapi.commons.log(err.message, 'error')
})
}
});
return ctx.body = yapi.commons.resReturn('成功!')
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
}
}
module.exports = interfaceController;

View File

@ -62,6 +62,10 @@ class interfaceColController extends baseController {
}
}
let result = await this.colModel.list(id);
result = result.sort((a, b) => {
return a.index - b.index;
});
for (let i = 0; i < result.length; i++) {
result[i] = result[i].toObject();
@ -136,7 +140,7 @@ class interfaceColController extends baseController {
}
/**
* 获取一个接口集下的所有的接口用例
* 获取一个接口集下的所有的测试用例
* @interface /col/case_list
* @method GET
* @category col
@ -151,42 +155,16 @@ class interfaceColController extends baseController {
if (!id || id == 0) {
return ctx.body = yapi.commons.resReturn(null, 407, 'col_id不能为空')
}
let resultList = await this.caseModel.list(id, 'all');
let colData = await this.colModel.get(id);
let project = await this.projectModel.getBaseInfo(colData.project_id);
if (project.project_type === 'private') {
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
}
}
for (let index = 0; index < resultList.length; index++) {
let result = resultList[index].toObject();
let data = await this.interfaceModel.get(result.interface_id);
if (!data) {
await this.caseModel.del(result._id);
continue;
}
let projectData = await this.projectModel.getBaseInfo(data.project_id);
result.path = projectData.basepath + data.path;
result.method = data.method;
result.req_body_type = data.req_body_type;
result.req_headers = this.handleParamsValue(data.req_headers, result.req_headers);
result.res_body_type = data.res_body_type;
result.req_body_form = this.handleParamsValue(data.req_body_form, result.req_body_form)
result.req_query = this.handleParamsValue(data.req_query, result.req_query)
result.req_params = this.handleParamsValue(data.req_params, result.req_params)
resultList[index] = result;
}
resultList = resultList.sort((a, b) => {
return a.index - b.index;
});
let ctxBody = yapi.commons.resReturn(resultList);
ctxBody.colData = colData;
ctx.body = ctxBody;
ctx.body = await yapi.commons.getCaseList(id);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
@ -204,7 +182,7 @@ class interfaceColController extends baseController {
}
/**
* 获取一个接口集下的所有的接口用例
* 获取一个接口集下的所有的测试用例
* @interface /col/case_list_by_var_params
* @method GET
* @category col
@ -265,7 +243,7 @@ class interfaceColController extends baseController {
}
/**
* 增加一个接口用例
* 增加一个测试用例
* @interface /col/add_case
* @method POST
* @category col
@ -328,7 +306,7 @@ class interfaceColController extends baseController {
this.colModel.get(params.col_id).then((col) => {
yapi.commons.saveLog({
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 在接口集 <a href="/project/${params.project_id}/interface/col/${params.col_id}">${col.name}</a> 下添加了接口用例 <a href="/project/${params.project_id}/interface/case/${result._id}">${params.casename}</a>`,
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 在接口集 <a href="/project/${params.project_id}/interface/col/${params.col_id}">${col.name}</a> 下添加了测试用例 <a href="/project/${params.project_id}/interface/case/${result._id}">${params.casename}</a>`,
type: 'project',
uid: this.getUid(),
username: username,
@ -384,11 +362,11 @@ class interfaceColController extends baseController {
data.casename = interfaceData.title;
data.req_body_other = interfaceData.req_body_other;
data.req_body_type = interfaceData.req_body_type;
await this.caseModel.save(data);
let caseResultData= await this.caseModel.save(data);
let username = this.getUsername();
this.colModel.get(params.col_id).then((col) => {
yapi.commons.saveLog({
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 在接口集 <a href="/project/${params.project_id}/interface/col/${params.col_id}">${col.name}</a> 下导入了接口 <a href="/project/${params.project_id}/interface/case/${data.interface_id}">${data.casename}</a>`,
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 在接口集 <a href="/project/${params.project_id}/interface/col/${params.col_id}">${col.name}</a> 下导入了测试用例 <a href="/project/${params.project_id}/interface/case/${caseResultData._id}">${data.casename}</a>`,
type: 'project',
uid: this.getUid(),
username: username,
@ -513,7 +491,7 @@ class interfaceColController extends baseController {
/**
* 更新一个接口用例
* 更新一个测试用例
* @interface /col/up_case
* @method POST
* @category col
@ -559,7 +537,7 @@ class interfaceColController extends baseController {
let username = this.getUsername();
this.colModel.get(caseData.col_id).then((col) => {
yapi.commons.saveLog({
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 在接口集 <a href="/project/${caseData.project_id}/interface/col/${caseData.col_id}">${col.name}</a> 更新了接口用例 <a href="/project/${caseData.project_id}/interface/case/${params.id}">${params.casename || caseData.casename}</a>`,
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 在接口集 <a href="/project/${caseData.project_id}/interface/col/${caseData.col_id}">${col.name}</a> 更新了测试用例 <a href="/project/${caseData.project_id}/interface/case/${params.id}">${params.casename || caseData.casename}</a>`,
type: 'project',
uid: this.getUid(),
username: username,
@ -577,7 +555,7 @@ class interfaceColController extends baseController {
}
/**
* 获取一个接口用例详情
* 获取一个测试用例详情
* @interface /col/case
* @method GET
* @category col
@ -604,12 +582,12 @@ class interfaceColController extends baseController {
result.path = projectData.basepath + data.path;
result.method = data.method;
result.req_body_type = data.req_body_type;
result.req_headers = this.handleParamsValue(data.req_headers, result.req_headers);
result.req_headers = yapi.commons.handleParamsValue(data.req_headers, result.req_headers);
result.res_body = data.res_body;
result.res_body_type = data.res_body_type;
result.req_body_form = this.handleParamsValue(data.req_body_form, result.req_body_form)
result.req_query = this.handleParamsValue(data.req_query, result.req_query)
result.req_params = this.handleParamsValue(data.req_params, result.req_params)
result.req_body_form = yapi.commons.handleParamsValue(data.req_body_form, result.req_body_form)
result.req_query = yapi.commons.handleParamsValue(data.req_query, result.req_query)
result.req_params = yapi.commons.handleParamsValue(data.req_params, result.req_params)
result.interface_up_time = data.up_time;
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
@ -617,31 +595,7 @@ class interfaceColController extends baseController {
}
}
/**
*
* @param {*} params 接口定义的参数
* @param {*} val 接口case 定义的参数值
*/
handleParamsValue(params, val) {
let value = {};
try {
params = params.toObject();
} catch (e) { }
if (params.length === 0 || val.length === 0) {
return params;
}
val.forEach((item, index) => {
value[item.name] = item;
})
params.forEach((item, index) => {
if (!value[item.name] || typeof value[item.name] !== 'object') return null;
params[index].value = value[item.name].value;
if (!_.isUndefined(value[item.name].enable)) {
params[index].enable = value[item.name].enable
}
})
return params;
}
/**
* 更新一个接口集name或描述
@ -689,7 +643,7 @@ class interfaceColController extends baseController {
/**
* 更新多个接口case index
* @interface /col/up_col_index
* @interface /col/up_case_index
* @method POST
* @category col
* @foldnumber 10
@ -719,6 +673,40 @@ class interfaceColController extends baseController {
}
}
/**
* 更新多个测试集合 index
* @interface /col/up_col_index
* @method POST
* @category col
* @foldnumber 10
* @param {Array} [id, index]
* @returns {Object}
* @example
*/
async upColIndex(ctx) {
try {
let params = ctx.request.body;
if (!params || !Array.isArray(params)) {
ctx.body = yapi.commons.resReturn(null, 400, "请求参数必须是数组")
}
params.forEach((item) => {
if (item.id) {
this.colModel.upColIndex(item.id, item.index).then((res) => { }, (err) => {
yapi.commons.log(err.message, 'error')
})
}
});
return ctx.body = yapi.commons.resReturn('成功!')
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
}
/**
* 删除一个接口集
* @interface /col/del_col
@ -802,48 +790,9 @@ class interfaceColController extends baseController {
}
}
convertString(variable) {
if (variable instanceof Error) {
return variable.name + ': ' + variable.message;
}
try {
return JSON.stringify(variable, null, ' ');
} catch (err) {
return variable || '';
}
}
async runCaseScript(ctx) {
let params = ctx.request.body;
let script = params.script;
if (!script) {
return ctx.body = yapi.commons.resReturn('ok');
}
let logs = [];
let result = {
assert: require('assert'),
status: params.response.status,
body: params.response.body,
header: params.response.header,
records: params.records,
params: params.params,
log: (msg) => {
logs.push('log: ' + this.convertString(msg))
}
}
try {
result = yapi.commons.sandbox(result, script);
result.logs = logs;
return ctx.body = yapi.commons.resReturn(result);
} catch (err) {
logs.push(this.convertString(err));
result.logs = logs;
return ctx.body = yapi.commons.resReturn(result, 400, err.name + ": " + err.message)
}
ctx.body = await yapi.commons.runCaseScript(params);
}
}

View File

@ -38,6 +38,8 @@ const commons = require('../utils/commons.js');
const userModel = require('../models/user.js');
const logModel = require('../models/log.js');
const followModel = require('../models/follow.js');
const tokenModel = require('../models/token.js');
const sha = require('sha.js');
class projectController extends baseController {
@ -48,6 +50,7 @@ class projectController extends baseController {
this.groupModel = yapi.getInst(groupModel);
this.logModel = yapi.getInst(logModel);
this.followModel = yapi.getInst(followModel);
this.tokenModel = yapi.getInst(tokenModel);
const id = 'number';
const member_uid = ['number'];
@ -109,6 +112,12 @@ class projectController extends baseController {
"*id": id,
"*member_uid": id,
role
},
token: {
'*project_id':id
},
updateToken: {
'*project_id':id
}
}
@ -224,6 +233,10 @@ class projectController extends baseController {
});
ctx.body = yapi.commons.resReturn(result);
}
/**
* 添加项目成员
* @interface /project/add_member
@ -722,6 +735,67 @@ class projectController extends baseController {
return s.size !== arr.length
}
/**
* 获取token数据
* @interface /project/token
* @method GET
* @category project
* @foldnumber 10
* @param {Number} id 项目id不能为空
* @param {String} q
* @return {Object}
*/
async token(ctx) {
try {
let project_id = ctx.params.project_id ;
let data = await this.tokenModel.get(project_id);
let token;
if (!data ) {
let passsalt = yapi.commons.randStr();
token = sha('sha1').update(passsalt).digest('hex').substr(0, 20);
await this.tokenModel.save({project_id, token})
} else {
token = data.token;
}
ctx.body = yapi.commons.resReturn(token);
} catch (err) {
ctx.body = yapi.commons.resReturn(null, 402, err.message);
}
}
/**
* 更新token数据
* @interface /project/update_token
* @method GET
* @category project
* @foldnumber 10
* @param {Number} id 项目id不能为空
* @param {String} q
* @return {Object}
*/
async updateToken(ctx) {
try {
let project_id = ctx.params.project_id ;
let data = await this.tokenModel.get(project_id);
let token, result;
if (data && data.token ) {
let passsalt = yapi.commons.randStr();
token = sha('sha1').update(passsalt).digest('hex').substr(0, 20);
result = await this.tokenModel.up(project_id, token)
result.token = token
} else {
ctx.body = yapi.commons.resReturn(null, 402, '没有查到token信息');
}
ctx.body = yapi.commons.resReturn(result);
} catch (err) {
ctx.body = yapi.commons.resReturn(null, 402, err.message);
}
}
/**
* 模糊搜索项目名称或者组名称
* @interface /project/search

View File

@ -2,15 +2,14 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 接口管理平台 使用手册</title>
<meta name="keywords" content="api管理,接口管理,接口文档,api文档">
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
<link rel="shortcut icon" href="./images/favicon.ico" />
<link rel="shortcut icon" href="./favicon.ico" />
<link rel="stylesheet" href="source/main.css" />
@ -18,10 +17,6 @@
<link rel="stylesheet" href="styles/theme.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
<div class="ydoc">