docs: 更新测试集合的变量参数部分文档
BIN
doc/images/usage/case_key_list.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
doc/images/usage/case_key_query.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
doc/images/usage/case_key_res.png
Normal file
After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 48 KiB |
@ -20,16 +20,19 @@ Mock 参数每次请求都会生成随机字符串
|
|||||||
|
|
||||||
#### 变量参数
|
#### 变量参数
|
||||||
|
|
||||||
<img class="doc-img" style="width:100%" src="./images/usage/mock-var-param.jpg" />
|
YApi 提供了强大的变量参数功能,你可以在测试的时候使用 `前面接口的返回值` 作为 `后面接口的参数`,即使接口之间存在依赖,也可以 **一键测试~**
|
||||||
|
|
||||||
|
例如:现有两个接口,分别是“导航标题”和“文章列表”
|
||||||
|
|
||||||
$.371.data._id
|
<img class="doc-img" style="width: 678px;" src="./images/usage/case_key_list.png" />
|
||||||
|
|
||||||
$. 是使用动态变量的标志
|
文章列表接口需要传参数: `当前标题(id)`,而这个 id 需要通过 `导航标题` 的返回值获取,这时应在 `文章列表` 的参数输入框中根据前者的 key 找到对应 id。
|
||||||
|
|
||||||
371 是用例 key ,可在用例列表查看到
|
|
||||||
|
|
||||||
data._id 是接口返回数据指向的实际字段
|
|
||||||
|
|
||||||
|
`导航标题` 的返回值:
|
||||||
|
<img class="doc-img" style="width: 122px;" src="./images/usage/case_key_res.png" />
|
||||||
|
|
||||||
|
`文章列表` 的参数配置:
|
||||||
|
<img class="doc-img" style="width: 682px;" src="./images/usage/case_key_query.png" />
|
||||||
|
$. 是使用动态变量的标志,**$.269 即表示 key 值为 269 的用例返回的数据**。
|
||||||
|
|
||||||
|
> Tips: 上下拖动测试集合的列表项可以调整测试的顺序。
|
||||||
|
@ -4292,7 +4292,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#16" target="_blank">./server/controllers/interfaceCol.js:16</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#17" target="_blank">./server/controllers/interfaceCol.js:17</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4354,7 +4354,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#47" target="_blank">./server/controllers/interfaceCol.js:47</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#48" target="_blank">./server/controllers/interfaceCol.js:48</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4440,7 +4440,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#105" target="_blank">./server/controllers/interfaceCol.js:105</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#106" target="_blank">./server/controllers/interfaceCol.js:106</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4502,7 +4502,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#158" target="_blank">./server/controllers/interfaceCol.js:158</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#159" target="_blank">./server/controllers/interfaceCol.js:159</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4684,7 +4684,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#298" target="_blank">./server/controllers/interfaceCol.js:298</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#299" target="_blank">./server/controllers/interfaceCol.js:299</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4854,7 +4854,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#367" target="_blank">./server/controllers/interfaceCol.js:367</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#368" target="_blank">./server/controllers/interfaceCol.js:368</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4916,7 +4916,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#426" target="_blank">./server/controllers/interfaceCol.js:426</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#435" target="_blank">./server/controllers/interfaceCol.js:435</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -4990,7 +4990,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#468" target="_blank">./server/controllers/interfaceCol.js:468</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#477" target="_blank">./server/controllers/interfaceCol.js:477</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -5050,7 +5050,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<small class="text-muted">源码位置:</small>
|
<small class="text-muted">源码位置:</small>
|
||||||
<a href="./static/server/controllers/interfaceCol.js.html#500" target="_blank">./server/controllers/interfaceCol.js:500</a>
|
<a href="./static/server/controllers/interfaceCol.js.html#509" target="_blank">./server/controllers/interfaceCol.js:509</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,11 +170,18 @@
|
|||||||
<p>测试完成之后,点击报告查看该次请求的结果</p>
|
<p>测试完成之后,点击报告查看该次请求的结果</p>
|
||||||
<h2 class="subject" id="编辑测试用例">编辑测试用例 <a class="hashlink" href="#编辑测试用例">#</a></h2><h3 class="subject" id="Mock参数">Mock参数 <a class="hashlink" href="#Mock参数">#</a></h3><p>Mock 参数每次请求都会生成随机字符串</p>
|
<h2 class="subject" id="编辑测试用例">编辑测试用例 <a class="hashlink" href="#编辑测试用例">#</a></h2><h3 class="subject" id="Mock参数">Mock参数 <a class="hashlink" href="#Mock参数">#</a></h3><p>Mock 参数每次请求都会生成随机字符串</p>
|
||||||
<p><img class="doc-img" style="width:100%" src="./images/usage/case-edit.jpg" /></p>
|
<p><img class="doc-img" style="width:100%" src="./images/usage/case-edit.jpg" /></p>
|
||||||
<h4 class="subject" id="变量参数">变量参数 <a class="hashlink" href="#变量参数">#</a></h4><p><img class="doc-img" style="width:100%" src="./images/usage/mock-var-param.jpg" /></p>
|
<h4 class="subject" id="变量参数">变量参数 <a class="hashlink" href="#变量参数">#</a></h4><p>YApi 提供了强大的变量参数功能,你可以在测试的时候使用 <code>前面接口的返回值</code> 作为 <code>后面接口的参数</code>,即使接口之间存在依赖,也可以 <strong>一键测试~</strong></p>
|
||||||
<pre><code> $.<span class="token number">371</span>.data._id
|
<p>例如:现有两个接口,分别是“导航标题”和“文章列表”</p>
|
||||||
</code></pre><p>$. 是使用动态变量的标志</p>
|
<p><img class="doc-img" style="width: 678px;" src="./images/usage/case_key_list.png" /></p>
|
||||||
<p>371 是用例 key ,可在用例列表查看到</p>
|
<p>文章列表接口需要传参数: <code>当前标题(id)</code>,而这个 id 需要通过 <code>导航标题</code> 的返回值获取,这时应在 <code>文章列表</code> 的参数输入框中根据前者的 key 找到对应 id。</p>
|
||||||
<p>data._id 是接口返回数据指向的实际字段</p>
|
<p><code>导航标题</code> 的返回值:
|
||||||
|
<img class="doc-img" style="width: 122px;" src="./images/usage/case_key_res.png" /></p>
|
||||||
|
<p><code>文章列表</code> 的参数配置:
|
||||||
|
<img class="doc-img" style="width: 682px;" src="./images/usage/case_key_query.png" />
|
||||||
|
$. 是使用动态变量的标志,<strong>$.269 即表示 key 值为 269 的用例返回的数据</strong>。</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>Tips: 上下拖动测试集合的列表项可以调整测试的顺序。</p>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
BIN
static/doc/images/usage/case_key_list.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
static/doc/images/usage/case_key_query.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
static/doc/images/usage/case_key_res.png
Normal file
After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 48 KiB |
@ -86,6 +86,24 @@
|
|||||||
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
|
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
|
||||||
<ul class="nav docs-sidenav">
|
<ul class="nav docs-sidenav">
|
||||||
|
|
||||||
|
<!-- <li > -->
|
||||||
|
<li >
|
||||||
|
|
||||||
|
<a href="#1.1.2">1.1.2</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<ul class="nav docs-sidenav-extend" >
|
||||||
|
|
||||||
|
<li >
|
||||||
|
<a href="#Features">Features</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li >
|
||||||
|
<a href="#Bug_Fixed">Bug Fixed</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
<!-- <li > -->
|
<!-- <li > -->
|
||||||
<li >
|
<li >
|
||||||
|
|
||||||
@ -156,6 +174,10 @@
|
|||||||
|
|
||||||
<div class="content-right markdown-body use-sidebar" role="main">
|
<div class="content-right markdown-body use-sidebar" role="main">
|
||||||
|
|
||||||
|
<h2 class="subject" id="1.1.2">1.1.2 <a class="hashlink" href="#1.1.2">#</a></h2><h3 class="subject" id="Features">Features <a class="hashlink" href="#Features">#</a></h3><ul>
|
||||||
|
<li>接口运行增加了 query 和 body 的 enable 选项,可选择是否请求该字段</li><li>Mock 支持了时间戳占位符 @timestamp</li></ul>
|
||||||
|
<h3 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h3><ul>
|
||||||
|
<li>修复了接口集运行功能会忽略 domain path 的 bug</li></ul>
|
||||||
<h2 class="subject" id="1.1.1">1.1.1 <a class="hashlink" href="#1.1.1">#</a></h2><h3 class="subject" id="Features">Features <a class="hashlink" href="#Features">#</a></h3><ul>
|
<h2 class="subject" id="1.1.1">1.1.1 <a class="hashlink" href="#1.1.1">#</a></h2><h3 class="subject" id="Features">Features <a class="hashlink" href="#Features">#</a></h3><ul>
|
||||||
<li>添加插件开发文档</li><li>接口和测试用例可拖动</li><li>优化动态提示</li></ul>
|
<li>添加插件开发文档</li><li>接口和测试用例可拖动</li><li>优化动态提示</li></ul>
|
||||||
<h3 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h3><ul>
|
<h3 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h3><ul>
|
||||||
|
@ -8,6 +8,7 @@ $(document).ready(function() {
|
|||||||
var $versionSelector = $('.version-selector');
|
var $versionSelector = $('.version-selector');
|
||||||
var $versionMask = $('.m-version-mask');
|
var $versionMask = $('.m-version-mask');
|
||||||
var isPanelHide = true;
|
var isPanelHide = true;
|
||||||
|
var winWidth = $(window).width();
|
||||||
var h2 = $('.content-right').find('h2');
|
var h2 = $('.content-right').find('h2');
|
||||||
var h3 = $('.content-right').find('h3');
|
var h3 = $('.content-right').find('h3');
|
||||||
var a = $('.content-left').find('a');
|
var a = $('.content-left').find('a');
|
||||||
|
@ -31,6 +31,7 @@ const interfaceModel = require('../models/interface.js');
|
|||||||
const projectModel = require('../models/project.js');
|
const projectModel = require('../models/project.js');
|
||||||
const baseController = require('./base.js');
|
const baseController = require('./base.js');
|
||||||
const yapi = require('../yapi.js');
|
const yapi = require('../yapi.js');
|
||||||
|
const _ = require('underscore');
|
||||||
|
|
||||||
class interfaceColController extends baseController{
|
class interfaceColController extends baseController{
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
@ -433,6 +434,11 @@ class interfaceColController extends baseController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} params 接口定义的参数
|
||||||
|
* @param {*} val 接口case 定义的参数值
|
||||||
|
*/
|
||||||
handleParamsValue(params, val){
|
handleParamsValue(params, val){
|
||||||
let value = {};
|
let value = {};
|
||||||
try{
|
try{
|
||||||
@ -447,6 +453,9 @@ class interfaceColController extends baseController{
|
|||||||
params.forEach((item, index)=>{
|
params.forEach((item, index)=>{
|
||||||
if(!value[item.name] || typeof value[item.name] !== 'object') return null;
|
if(!value[item.name] || typeof value[item.name] !== 'object') return null;
|
||||||
params[index].value = value[item.name].value;
|
params[index].value = value[item.name].value;
|
||||||
|
if(!_.isUndefined(value[item.name].enable)){
|
||||||
|
params[index].enable = value[item.name].enable
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ class projectController extends baseController {
|
|||||||
let result = await this.Model.up(id, data);
|
let result = await this.Model.up(id, data);
|
||||||
let username = this.getUsername();
|
let username = this.getUsername();
|
||||||
yapi.commons.saveLog({
|
yapi.commons.saveLog({
|
||||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/user/profile/${id}}">${projectData.name}</a>`,
|
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/project/${id}/interface/api}">${projectData.name}</a>`,
|
||||||
type: 'project',
|
type: 'project',
|
||||||
uid: this.getUid(),
|
uid: this.getUid(),
|
||||||
username: username,
|
username: username,
|
||||||
@ -687,7 +687,7 @@ class projectController extends baseController {
|
|||||||
let result = await this.Model.up(id, data);
|
let result = await this.Model.up(id, data);
|
||||||
let username = this.getUsername();
|
let username = this.getUsername();
|
||||||
yapi.commons.saveLog({
|
yapi.commons.saveLog({
|
||||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/user/profile/${id}">${projectData.name}</a> 的环境`,
|
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/project/${id}/interface/api">${projectData.name}</a> 的环境`,
|
||||||
type: 'project',
|
type: 'project',
|
||||||
uid: this.getUid(),
|
uid: this.getUid(),
|
||||||
username: username,
|
username: username,
|
||||||
|