docs: doc

This commit is contained in:
suxiaoxin 2018-03-06 16:50:24 +08:00
commit 5bbc848a92
27 changed files with 105 additions and 66 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

View File

@ -1,6 +1,6 @@
## Mock介绍
<p style='text-indent:2em;line-height:1.8em'>YApi的 Mock 功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、mock 规则([点击到 Mock 规则](#mock))生成 Mock 接口,这些接口会自动生成模拟数据,创建者可以自由构造需要的数据。而且与常见的 Mock 方式如将 Mock 写在代码里和JS拦截等相比 yapi 的 Mock 在使用场景和效率和复杂度上是相差甚远的,正是由于 yapi 的 Mock 是一个第三方平台,那么在团队开发时任何人都可以权限许可下创建、修改接口信息等操作,这对于团队开发是很有好处的</p>
<p style='text-indent:2em;line-height:1.8em'>YApi的 Mock 功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、返回数据([返回数据](#mock))生成 Mock 接口,这些接口会自动生成模拟数据,创建者可以自由构造需要的数据。 </p>
**mock地址解析**`YApi平台网址 + mock + 您的项目id + 接口实际请求path`
@ -11,28 +11,12 @@
> 注:项目 id 可以在项目设置里查看到
## 定义 mock 数据示例
```
{
"status|0-1": 0, //接口状态
"message": "请求完成", //消息提示
"data": {
"counts":"@integer", //统计数量
"totalSubjectType|4-10": [ //4-10意味着可以随机生成4-10组数据
{
"subjectName|regexp": "大数据|机器学习|工具", //主题名
"subjectType|+1": 1 //类型
}
],
"data":[
{
"name": "@name", //用户名
"email": "@email", //email
"time": "@datetime" //时间
}
]}
}
```
项目 -> 接口编辑 -> 返回数据设置
<img src="./images/usage/mock-demo.jpg" />
> 注:开启 json-schema 功能后,将不再使用 mockjs 解析定义的返回数据,而是根据 json-schema 定义的数据结构,生成随机数据。
## YApi-Mock 跟 Mockjs 区别

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="active">
@ -3521,7 +3521,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#117" target="_blank">./server/controllers/interface.js:117</a>
=======
<a href="./static/server/controllers/interface.js.html#104" target="_blank">./server/controllers/interface.js:104</a>
>>>>>>> doc
</p>
@ -3842,7 +3846,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#216" target="_blank">./server/controllers/interface.js:216</a>
=======
<a href="./static/server/controllers/interface.js.html#204" target="_blank">./server/controllers/interface.js:204</a>
>>>>>>> doc
</p>
@ -4090,7 +4098,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#290" target="_blank">./server/controllers/interface.js:290</a>
=======
<a href="./static/server/controllers/interface.js.html#278" target="_blank">./server/controllers/interface.js:278</a>
>>>>>>> doc
</p>
@ -4155,7 +4167,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#331" target="_blank">./server/controllers/interface.js:331</a>
=======
<a href="./static/server/controllers/interface.js.html#319" target="_blank">./server/controllers/interface.js:319</a>
>>>>>>> doc
</p>
@ -4244,7 +4260,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#458" target="_blank">./server/controllers/interface.js:458</a>
=======
<a href="./static/server/controllers/interface.js.html#417" target="_blank">./server/controllers/interface.js:417</a>
>>>>>>> doc
</p>
@ -4477,7 +4497,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#618" target="_blank">./server/controllers/interface.js:618</a>
=======
<a href="./static/server/controllers/interface.js.html#577" target="_blank">./server/controllers/interface.js:577</a>
>>>>>>> doc
</p>
@ -4549,7 +4573,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#816" target="_blank">./server/controllers/interface.js:816</a>
=======
<a href="./static/server/controllers/interface.js.html#775" target="_blank">./server/controllers/interface.js:775</a>
>>>>>>> doc
</p>
@ -4614,7 +4642,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interface.js.html#848" target="_blank">./server/controllers/interface.js:848</a>
=======
<a href="./static/server/controllers/interface.js.html#807" target="_blank">./server/controllers/interface.js:807</a>
>>>>>>> doc
</p>
@ -5239,7 +5271,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#156" target="_blank">./server/controllers/interfaceCol.js:156</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#152" target="_blank">./server/controllers/interfaceCol.js:152</a>
>>>>>>> doc
</p>
@ -5301,7 +5337,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#217" target="_blank">./server/controllers/interfaceCol.js:217</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#213" target="_blank">./server/controllers/interfaceCol.js:213</a>
>>>>>>> doc
</p>
@ -5483,7 +5523,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#465" target="_blank">./server/controllers/interfaceCol.js:465</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#461" target="_blank">./server/controllers/interfaceCol.js:461</a>
>>>>>>> doc
</p>
@ -5653,7 +5697,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#529" target="_blank">./server/controllers/interfaceCol.js:529</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#525" target="_blank">./server/controllers/interfaceCol.js:525</a>
>>>>>>> doc
</p>
@ -5715,7 +5763,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#572" target="_blank">./server/controllers/interfaceCol.js:572</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#568" target="_blank">./server/controllers/interfaceCol.js:568</a>
>>>>>>> doc
</p>
@ -5849,7 +5901,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#649" target="_blank">./server/controllers/interfaceCol.js:649</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#612" target="_blank">./server/controllers/interfaceCol.js:612</a>
>>>>>>> doc
</p>
@ -5909,7 +5965,11 @@
<p>
<small class="text-muted">源码位置:</small>
<<<<<<< HEAD
<a href="./static/server/controllers/interfaceCol.js.html#682" target="_blank">./server/controllers/interfaceCol.js:682</a>
=======
<a href="./static/server/controllers/interfaceCol.js.html#644" target="_blank">./server/controllers/interfaceCol.js:644</a>
>>>>>>> doc
</p>

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">
@ -181,7 +181,7 @@
<div class="content-right markdown-body use-sidebar" role="main">
<h2 class="subject" id="Mock介绍">Mock介绍 <a class="hashlink" href="#Mock介绍">#</a></h2> <p style='text-indent:2em;line-height:1.8em'>YApi的 Mock 功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、mock 规则(<a href="#mock">点击到 Mock 规则</a>)生成 Mock 接口,这些接口会自动生成模拟数据,创建者可以自由构造需要的数据。而且与常见的 Mock 方式如将 Mock 写在代码里和JS拦截等相比 yapi 的 Mock 在使用场景和效率和复杂度上是相差甚远的,正是由于 yapi 的 Mock 是一个第三方平台,那么在团队开发时任何人都可以权限许可下创建、修改接口信息等操作,这对于团队开发是很有好处的</p>
<h2 class="subject" id="Mock介绍">Mock介绍 <a class="hashlink" href="#Mock介绍">#</a></h2> <p style='text-indent:2em;line-height:1.8em'>YApi的 Mock 功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、返回数据(<a href="#mock">返回数据</a>)生成 Mock 接口,这些接口会自动生成模拟数据,创建者可以自由构造需要的数据。 </p>
<p> <strong>mock地址解析</strong><code>YApi平台网址 + mock + 您的项目id + 接口实际请求path</code></p>
<p> 假设你 YApi 的部署地址为:<a href="http://yapi.xxx.com">http://yapi.xxx.com</a> 然后用这个地址作为示例</p>
@ -189,26 +189,12 @@
</code></pre><blockquote>
<p>注:项目 id 可以在项目设置里查看到</p>
</blockquote>
<h2 class="subject" id="定义_mock_数据示例">定义 mock 数据示例 <a class="hashlink" href="#定义_mock_数据示例">#</a></h2><pre><code><span class="token punctuation">{</span>
<span class="token property">"status|0-1"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span> //接口状态
<span class="token property">"message"</span><span class="token operator">:</span> <span class="token string">"请求完成"</span><span class="token punctuation">,</span> //消息提示
<span class="token property">"data"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"counts"</span><span class="token operator">:</span><span class="token string">"@integer"</span><span class="token punctuation">,</span> //统计数量
<span class="token property">"totalSubjectType|4-10"</span><span class="token operator">:</span> <span class="token punctuation">[</span> //<span class="token number">4</span>-<span class="token number">10</span>意味着可以随机生成<span class="token number">4</span>-<span class="token number">10</span>组数据
<span class="token punctuation">{</span>
<span class="token property">"subjectName|regexp"</span><span class="token operator">:</span> <span class="token string">"大数据|机器学习|工具"</span><span class="token punctuation">,</span> //主题名
<span class="token property">"subjectType|+1"</span><span class="token operator">:</span> <span class="token number">1</span> //类型
<span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"data"</span><span class="token operator">:</span><span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"@name"</span><span class="token punctuation">,</span> //用户名
<span class="token property">"email"</span><span class="token operator">:</span> <span class="token string">"@email"</span><span class="token punctuation">,</span> //email
<span class="token property">"time"</span><span class="token operator">:</span> <span class="token string">"@datetime"</span> //时间
<span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><h2 class="subject" id="YApi-Mock_跟_Mockjs_区别">YApi-Mock 跟 Mockjs 区别 <a class="hashlink" href="#YApi-Mock_跟_Mockjs_区别">#</a></h2><p><a href="http://mockjs.com/examples.html">Mockjs 官网</a></p>
<h2 class="subject" id="定义_mock_数据示例">定义 mock 数据示例 <a class="hashlink" href="#定义_mock_数据示例">#</a></h2><p>项目 -&gt; 接口编辑 -&gt; 返回数据设置</p>
<p><img src="./images/usage/mock-demo.jpg" /></p>
<blockquote>
<p>注:开启 json-schema 功能后,将不再使用 mockjs 解析定义的返回数据,而是根据 json-schema 定义的数据结构,生成随机数据。</p>
</blockquote>
<h2 class="subject" id="YApi-Mock_跟_Mockjs_区别">YApi-Mock 跟 Mockjs 区别 <a class="hashlink" href="#YApi-Mock_跟_Mockjs_区别">#</a></h2><p><a href="http://mockjs.com/examples.html">Mockjs 官网</a></p>
<p>1 因为 yapi 基于 json 定义 mock ,无法使用 mockjs 原有的函数功能,正则表达式需要基于 rule 书写,示例如下:</p>
<pre><code><span class="token punctuation">{</span>
<span class="token property">"name|regexp"</span><span class="token operator">:</span> <span class="token string">"[a-z0-9_]+?"</span><span class="token punctuation">,</span>

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">
@ -98,10 +98,13 @@
<ul class="nav docs-sidenav">
<li >
<<<<<<< HEAD
<a href="#v1.3.7">v1.3.7</a>
</li>
<li >
=======
>>>>>>> doc
<a href="#v1.3.6">v1.3.6</a>
</li>
@ -185,11 +188,15 @@
<div class="content-right markdown-body use-sidebar" role="main">
<<<<<<< HEAD
<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>
=======
<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>
>>>>>>> doc
<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>

View File

@ -61,7 +61,7 @@
<li class="">
<a href="http://yapi.demo.qunar.com/" target="_blank">demo 站点</a>
<a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a>
</li>
<li class="">

1
static/prd/assets.js Normal file
View File

@ -0,0 +1 @@
window.WEBPACK_ASSETS = {"index.js":{"js":"index@8e5948fa1c0717f0fb50.js","css":"index@8e5948fa1c0717f0fb50.css"},"lib":{"js":"lib@3ea2f24165e6a69854ca.js"},"lib2":{"js":"lib2@6e5cbf5fa9841f21bafa.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}

View File

@ -0,0 +1 @@
!function(e){function n(t){if(r[t])return r[t].exports;var a=r[t]={exports:{},id:t,loaded:!1};return e[t].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}var t=window.webpackJsonp;window.webpackJsonp=function(o,p){for(var c,l,i=0,s=[];i<o.length;i++)l=o[i],a[l]&&s.push.apply(s,a[l]),a[l]=0;for(c in p)e[c]=p[c];for(t&&t(o,p);s.length;)s.shift().call(null,n);if(p[0])return r[0]=0,n(0)};var r={},a={3:0};n.e=function(e,t){if(0===a[e])return t.call(null,n);if(void 0!==a[e])a[e].push(t);else{a[e]=[t];var r=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.charset="utf-8",o.async=!0,o.src=n.p+""+e+".chunk.min.js",r.appendChild(o)}},n.m=e,n.c=r,n.p=""}([]);

View File

@ -214,8 +214,8 @@ module.exports = {
"menuLevel": 2,
"content": "./CHANGELOG.md"
},{
"name": "demo站点",
"title": "demo 站点",
"name": "产品演示",
"title": "产品演示",
"url": "http://yapi.demo.qunar.com/"
},
{