diff --git a/static/doc/api.html b/static/doc/api.html
index d890c991..57d44d75 100644
--- a/static/doc/api.html
+++ b/static/doc/api.html
@@ -3032,7 +3032,7 @@
源码位置:
- ./server/controllers/project.js:585
+ ./server/controllers/project.js:583
@@ -3127,7 +3127,7 @@
源码位置:
- ./server/controllers/project.js:639
+ ./server/controllers/project.js:637
@@ -3192,7 +3192,7 @@
源码位置:
- ./server/controllers/interface.js:18
+ ./server/controllers/interface.js:19
@@ -3513,7 +3513,7 @@
源码位置:
- ./server/controllers/interface.js:137
+ ./server/controllers/interface.js:155
@@ -3578,7 +3578,7 @@
源码位置:
- ./server/controllers/interface.js:162
+ ./server/controllers/interface.js:180
@@ -3643,7 +3643,7 @@
源码位置:
- ./server/controllers/interface.js:224
+ ./server/controllers/interface.js:242
@@ -3876,7 +3876,7 @@
源码位置:
- ./server/controllers/interface.js:379
+ ./server/controllers/interface.js:396
@@ -4805,7 +4805,7 @@
源码位置:
- ./server/controllers/interfaceCol.js:327
+ ./server/controllers/interfaceCol.js:329
@@ -4879,7 +4879,7 @@
源码位置:
- ./server/controllers/interfaceCol.js:368
+ ./server/controllers/interfaceCol.js:370
@@ -4939,7 +4939,7 @@
源码位置:
- ./server/controllers/interfaceCol.js:410
+ ./server/controllers/interfaceCol.js:412
diff --git a/static/doc/mock.html b/static/doc/mock.html
index 76c4b936..acae36ed 100644
--- a/static/doc/mock.html
+++ b/static/doc/mock.html
@@ -65,9 +65,53 @@
-
+
-
+
+
+
+
+
+
+
Mock介绍 #
yapi的Mock功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、mock规则(点击到Mock规则)生成Mock接口,这些接口会自动生成模拟数据,创建者可以自由构造需要的数据。而且与常见的Mock方式如将Mock写在代码里和JS拦截等相比yapi的Mock在使用场景和效率和复杂度上是相差甚远的,正是由于yapi的Mock是一个第三方平台,那么在团队开发时任何人都可以权限许可下创建、修改接口信息等操作,这对于团队开发是很有好处的。
mock地址解析:yapi平台网址+mock+您的项目id+接口实际请求path
注:项目id可以在项目设置里查看到
@@ -198,7 +242,7 @@ name
: {"full": "Charles Brenda Lopez"
}
-
+
@@ -212,6 +256,9 @@ name
: {
+
+
+
diff --git a/static/doc/start.html b/static/doc/start.html
index 27f1abc4..d57d88ae 100644
--- a/static/doc/start.html
+++ b/static/doc/start.html
@@ -65,9 +65,41 @@
-
+
-
+
+
+
+
+
+
+
快速开始 #
1 创建项目分组 #
登录之后进到项目首页,左边侧边栏显示的即分组列表。
联系管理员添加分组并且把你设置为组长或让组长邀请你加入到某项目分组
@@ -85,7 +117,7 @@
点击保存按钮可把当前测试保存到测试集,方便下次调试
-
+
@@ -99,6 +131,9 @@
+
+
+
diff --git a/static/doc/static/server/controllers/interface.js.html b/static/doc/static/server/controllers/interface.js.html
index de099954..51e2d81c 100644
--- a/static/doc/static/server/controllers/interface.js.html
+++ b/static/doc/static/server/controllers/interface.js.html
@@ -29,6 +29,7 @@
import interfaceCatModel from '../models/interfaceCat.js';
import interfaceCaseModel from '../models/interfaceCase.js'
+import _ from 'underscore';
import baseController from './base.js';
import yapi from '../yapi.js';
import userModel from '../models/user.js';
@@ -88,6 +89,7 @@ class interfaceController extends baseController {
}
params.method = params.method || 'GET';
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';
if (!params.project_id) {
@@ -132,7 +134,23 @@ class interfaceController extends baseController {
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
- if (params.req_params && Array.isArray(params.req_params) && params.req_params.length > 0) {
+
+ if (params.path.indexOf(":") > 0) {
+ let paths = params.path.split("/"), name, i;
+ for (i = 1; i < paths.length; i++) {
+ if (paths[i][0] === ':') {
+ name = paths[i].substr(1);
+ if (!_.find(params.req_params, { name: name })) {
+ params.req_params.push({
+ name: name,
+ desc: ''
+ })
+ }
+ }
+ }
+ }
+
+ if ( params.req_params.length > 0) {
data.type = 'var'
data.req_params = params.req_params;
} else {
@@ -143,9 +161,9 @@ class interfaceController extends baseController {
}
let result = await this.Model.save(data);
-
+
// let project = await this.projectModel.get(params.project_id);
- this.catModel.get(params.catid).then((cate)=>{
+ this.catModel.get(params.catid).then((cate) => {
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`,
@@ -155,7 +173,7 @@ class interfaceController extends baseController {
typeid: params.project_id
});
});
-
+
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -278,7 +296,6 @@ class interfaceController extends baseController {
async up(ctx) {
let params = ctx.request.body;
-
params = yapi.commons.handleParams(params, {
title: 'string',
path: 'string',
@@ -306,7 +323,7 @@ class interfaceController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/');
}
- if (params.path && params.path !== interfaceData.path && params.method !== interfaceData.method) {
+ if (params.path && (params.path !== interfaceData.path || params.method !== interfaceData.method)) {
let checkRepeat = await this.Model.checkRepeat(interfaceData.project_id, params.path, params.method);
if (checkRepeat > 0) {
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
@@ -317,28 +334,28 @@ class interfaceController extends baseController {
up_time: yapi.commons.time()
};
- if (params.path) {
+ if (!_.isUndefined(params.path)) {
data.path = params.path;
}
- if (params.title) {
+ if (!_.isUndefined(params.title)) {
data.title = params.title;
}
- if (params.desc) {
+ if (!_.isUndefined(params.desc)) {
data.desc = params.desc;
}
- if (params.method) {
+ if (!_.isUndefined(params.method)) {
data.method = params.method;
}
- if (params.catid) {
+ if (!_.isUndefined(params.catid)) {
data.catid = params.catid;
}
- if (params.req_headers) {
+ if (!_.isUndefined(params.req_headers)) {
data.req_headers = params.req_headers;
}
- if (params.req_body_form) {
+ if (!_.isUndefined(params.req_body_form)) {
data.req_body_form = params.req_body_form;
}
if (params.req_params && Array.isArray(params.req_params) && params.req_params.length > 0) {
@@ -348,25 +365,25 @@ class interfaceController extends baseController {
data.type = 'static'
}
- if (params.req_query) {
+ if (!_.isUndefined(params.req_query)) {
data.req_query = params.req_query;
}
- if (params.req_body_other) {
+ if (!_.isUndefined(params.req_body_other)) {
data.req_body_other = params.req_body_other;
}
- if (params.req_body_type) {
+ if (!_.isUndefined(params.req_body_type)) {
data.req_body_type = params.req_body_type;
}
- if (params.res_body_type) {
+ if (!_.isUndefined(params.res_body_type)) {
data.res_body_type = params.res_body_type;
}
- if (params.res_body) {
+ if (!_.isUndefined(params.res_body)) {
data.res_body = params.res_body;
}
- if (params.status) {
+ if (!_.isUndefined(params.status)) {
data.status = params.status;
}
@@ -374,7 +391,7 @@ class interfaceController extends baseController {
let result = await this.Model.up(id, data);
let username = this.getUsername();
if (params.catid) {
- this.catModel.get(+params.catid).then((cate)=>{
+ this.catModel.get(+params.catid).then((cate) => {
yapi.commons.saveLog({
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
type: 'project',
@@ -385,7 +402,7 @@ class interfaceController extends baseController {
});
} else {
let cateid = interfaceData.catid;
- this.catModel.get(cateid).then((cate)=>{
+ this.catModel.get(cateid).then((cate) => {
yapi.commons.saveLog({
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
type: 'project',
@@ -396,7 +413,7 @@ class interfaceController extends baseController {
});
}
-
+
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -436,7 +453,7 @@ class interfaceController extends baseController {
let result = await this.Model.del(id);
await this.caseModel.delByInterfaceId(id);
let username = this.getUsername();
- this.catModel.get(inter.catid).then((cate)=>{
+ this.catModel.get(inter.catid).then((cate) => {
yapi.commons.saveLog({
content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
type: 'project',
@@ -445,7 +462,7 @@ class interfaceController extends baseController {
typeid: cate.project_id
});
})
-
+
ctx.body = yapi.commons.resReturn(result);
} catch (err) {
@@ -535,7 +552,7 @@ class interfaceController extends baseController {
name: params.name,
desc: params.desc,
up_time: yapi.commons.time()
- });
+ });
let username = this.getUsername();
let cate = await this.catModel.get(params.catid);
diff --git a/static/doc/static/server/controllers/interfaceCol.js.html b/static/doc/static/server/controllers/interfaceCol.js.html
index ec7a7c0c..bd9decfc 100644
--- a/static/doc/static/server/controllers/interfaceCol.js.html
+++ b/static/doc/static/server/controllers/interfaceCol.js.html
@@ -52,7 +52,7 @@ class interfaceColController extends baseController{
* @example
*/
async list(ctx){
- try {
+ try {
let id = ctx.query.project_id;
let result = await this.colModel.list(id);
@@ -140,7 +140,7 @@ class interfaceColController extends baseController{
let inst = yapi.getInst(interfaceCaseModel);
let result = await inst.list(id, 'all');
for(let index=0; index< result.length; index++){
-
+
result[index] = result[index].toObject();
let interfaceData = await this.interfaceModel.getBaseinfo(result[index].interface_id);
let projectData = await this.projectModel.getBaseInfo(interfaceData.project_id);
@@ -224,8 +224,8 @@ class interfaceColController extends baseController{
typeid: params.project_id
});
});
-
-
+
+
ctx.body = yapi.commons.resReturn(result);
}catch(e){
@@ -292,8 +292,8 @@ class interfaceColController extends baseController{
typeid: caseData.project_id
});
});
-
-
+
+
ctx.body = yapi.commons.resReturn(result);
@@ -322,16 +322,18 @@ class interfaceColController extends baseController{
}
result = result.toObject();
let data = await this.interfaceModel.get(result.interface_id);
+ data = data.toObject();
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 = data.req_headers;
+
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)
-
+
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
@@ -429,7 +431,7 @@ class interfaceColController extends baseController{
// typeid: params.project_id
// });
- return ctx.body = yapi.commons.resReturn('success')
+ return ctx.body = yapi.commons.resReturn('成功!')
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
@@ -508,7 +510,7 @@ class interfaceColController extends baseController{
typeid: caseData.project_id
});
});
-
+
return ctx.body = yapi.commons.resReturn(result);
diff --git a/static/doc/static/server/controllers/project.js.html b/static/doc/static/server/controllers/project.js.html
index 2b194681..8b1b2895 100644
--- a/static/doc/static/server/controllers/project.js.html
+++ b/static/doc/static/server/controllers/project.js.html
@@ -371,7 +371,7 @@ class projectController extends baseController {
for(let index=0, item, r = 1; index< result.length; index++){
item = result[index].toObject();
if(item.project_type === 'private' && auth === false){
- r = await this.Model.checkMemberRepeat(this.getUid());
+ r = await this.Model.checkMemberRepeat(item._id, this.getUid());
if(r === 0){
continue;
}
@@ -458,7 +458,7 @@ class projectController extends baseController {
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目成员不存在');
}
- if (await this.checkAuth(params.id, 'group', 'danger') !== true) {
+ if (await this.checkAuth(params.id, 'project', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
@@ -587,14 +587,12 @@ class projectController extends baseController {
data.project_type = params.project_type
}
- if (params.name) data.name = params.name;
- if (params.desc) data.desc = params.desc;
- if (params.basepath) {
- data.basepath = params.basepath;
- }
- if (params.env) data.env = params.env;
- if (params.color) data.color = params.color;
- if (params.icon) data.icon = params.icon;
+ if (!_.isUndefined(params.name)) data.name = params.name;
+ if (!_.isUndefined(params.desc)) data.desc = params.desc;
+ data.basepath = params.basepath;
+ if (!_.isUndefined(params.env)) data.env = params.env;
+ if (!_.isUndefined(params.color)) data.color = params.color;
+ if (!_.isUndefined(params.icon)) data.icon = params.icon;
let result = await this.Model.up(id, data);
let username = this.getUsername();
yapi.commons.saveLog({
diff --git a/ydoc.json b/ydoc.json
index 45cd34fb..a1974321 100644
--- a/ydoc.json
+++ b/ydoc.json
@@ -12,15 +12,15 @@
"homeUrl": "http://ued.qunar.com/ymfe/" // logourl
},
"options": {
- "foldcode": true
- // "markdown": { // 对于 markdown 编译器进行统一配置
- // "menuLevel": 4 //选取第几级 head 作为目录,默认 -1 没有目录
- // }
+ "foldcode": true,
+ "markdown": { // 对于 markdown 编译器进行统一配置
+ "menuLevel": 2 //选取第几级 head 作为目录,默认 -1 没有目录
+ }
},
"pages": [{
"name": "index", // Page Name 会根据他生成 html 文件,例: index.html
"title": "首页", // Page Title
- "homepage": { // 配置首页,样式区别于其他页面
+ "homepage": { // 配置首页,样式区别于其他页面
"version": "v1.0.0", // 版本信息将显示在banner底部
"button": [{ // 按钮组将显示在banner底部
"name": "开始",