mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
e410285e9c
@ -2,7 +2,7 @@
|
||||
|
||||
#### Feature
|
||||
|
||||
* 数据导入同步
|
||||
* 数据导入同步,数据导入支持swagger 3.0
|
||||
|
||||
#### Bug Fixed
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* 修改编辑接口后,再回到测试集合处数据不更新问题
|
||||
* swagger 数据导入支持 2xx 的httpcode
|
||||
* 修复mongodb帐号密码配置错误时引发的错误
|
||||
* 修复删除分组后侧边数据没哟更新问题
|
||||
|
||||
### v1.3.4
|
||||
|
||||
|
@ -59,7 +59,7 @@ class InterfaceList extends Component {
|
||||
// })
|
||||
let r = await this.props.fetchInterfaceList(projectId);
|
||||
this.setState({
|
||||
data: JSON.parse(JSON.stringify(r.payload.data.data))
|
||||
data: r.payload.data.data
|
||||
})
|
||||
|
||||
} else if (isNaN(params.actionId)) {
|
||||
@ -90,6 +90,9 @@ class InterfaceList extends Component {
|
||||
if (this.actionId !== _actionId) {
|
||||
this.actionId = _actionId;
|
||||
this.handleRequest(nextProps)
|
||||
} else if( this.props.catList !== nextProps.catList){
|
||||
this.handleRequest(nextProps)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ class ProjectData extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
handleFile = (info) => {
|
||||
@ -193,6 +193,7 @@ class ProjectData extends Component {
|
||||
reader.readAsText(info.file);
|
||||
reader.onload = async res => {
|
||||
res = importDataModule[this.state.curImportType].run(res.target.result);
|
||||
console.log('res',res);
|
||||
if (this.state.dataSync) {
|
||||
// 开启同步
|
||||
this.showConfirm(res);
|
||||
@ -209,9 +210,16 @@ class ProjectData extends Component {
|
||||
|
||||
|
||||
showConfirm = async (res) => {
|
||||
|
||||
let that = this;
|
||||
let typeid = this.props.match.params.id;
|
||||
let result = await this.props.fetchUpdateLogData({ type: 'project', typeid, apis: res.apis })
|
||||
let apiCollections = res.apis.map(item=>{
|
||||
return {
|
||||
method:item.method,
|
||||
path: item.path
|
||||
}
|
||||
})
|
||||
let result = await this.props.fetchUpdateLogData({ type: 'project', typeid, apis: apiCollections })
|
||||
let domainData = result.payload.data.data;
|
||||
const ref = confirm({
|
||||
title: '您确认要进行数据同步????',
|
||||
|
@ -55,4 +55,7 @@
|
||||
汇通天下已部署使用 YApi
|
||||
* ![一键秀](./images/show.jpeg)
|
||||
|
||||
一键秀(一键生成)已部署使用 YApi
|
||||
一键秀(一键生成)已部署使用 YApi
|
||||
* ![用友](./images/yonyou.jpg)
|
||||
|
||||
用友已经部署使用YApi,并且自己开发了单点登录插件
|
||||
|
BIN
doc/images/yonyou.jpg
Normal file
BIN
doc/images/yonyou.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
@ -5,7 +5,7 @@ var jsf = require('common/json-schema-mockjs');
|
||||
|
||||
|
||||
function improtData(importDataModule) {
|
||||
var SwaggerData;
|
||||
var SwaggerData, isOAS3;
|
||||
function handlePath(path) {
|
||||
if (path.charAt(0) != "/") {
|
||||
path = "/" + path;
|
||||
@ -15,48 +15,44 @@ function improtData(importDataModule) {
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
function openapi2swagger(data) {
|
||||
data = data.replace(/components\/schemas/g, 'definitions');
|
||||
data = data.replace('openapi', 'swagger');
|
||||
data = JSON.parse(data);
|
||||
|
||||
data.definitions = data.components.schemas;
|
||||
delete data.components;
|
||||
|
||||
data.swagger = '2.0';
|
||||
|
||||
_.each(data.paths, (apis) => {
|
||||
_.each(apis, (api) => {
|
||||
_.each(api.responses, (res) => {
|
||||
if(res.content) {
|
||||
if (res.content) {
|
||||
res.schema = res.content['application/json'].schema;
|
||||
delete res.content;
|
||||
}
|
||||
})
|
||||
if(api.requestBody) {
|
||||
if(!api.parameters) api.parameters = [];
|
||||
if (api.requestBody) {
|
||||
if (!api.parameters) api.parameters = [];
|
||||
api.parameters.push({
|
||||
type: 'object',
|
||||
name: 'body',
|
||||
in: 'body',
|
||||
schema: {
|
||||
$ref: api.requestBody.content['application/json'].schema
|
||||
$ref: api.requestBody.content['application/json'].schema.$ref
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function run(res) {
|
||||
try {
|
||||
let interfaceData = { apis: [], cats: [] };
|
||||
if(res.includes('openapi')) {
|
||||
res = openapi2swagger(res);
|
||||
} else {
|
||||
res = JSON.parse(res);
|
||||
res = JSON.parse(res);
|
||||
isOAS3 = res.openapi && res.openapi === '3.0.0'
|
||||
if (isOAS3) {
|
||||
res = openapi2swagger(res)
|
||||
}
|
||||
|
||||
SwaggerData = res;
|
||||
if (res.tags && Array.isArray(res.tags)) {
|
||||
res.tags.forEach(tag => {
|
||||
@ -218,9 +214,11 @@ function improtData(importDataModule) {
|
||||
if (typeof data !== 'object') {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
data.definitions = SwaggerData.definitions;
|
||||
// data.definitions = SwaggerData.definitions;
|
||||
isOAS3 ? data.components = SwaggerData.components : data.definitions = SwaggerData.definitions
|
||||
|
||||
let jsfData = JSON.stringify(jsf(data), null, 2);
|
||||
return jsfData;
|
||||
} catch (e) {
|
||||
|
@ -246,7 +246,7 @@ class interfaceController extends baseController {
|
||||
}
|
||||
|
||||
let result = await this.Model.getByPath(params.project_id, params.path, params.method, '_id');
|
||||
console.log('result', result);
|
||||
|
||||
if (result.length > 0) {
|
||||
result.forEach(async item => {
|
||||
params.id = item._id;
|
||||
|
BIN
static/doc/images/yonyou.jpg
Normal file
BIN
static/doc/images/yonyou.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
@ -192,7 +192,9 @@
|
||||
</li><li><p><img src="http://www.g7.com.cn/static/image/logo.png" alt="汇通天下"></p>
|
||||
<p> 汇通天下已部署使用 YApi</p>
|
||||
</li><li><p><img src="./images/show.jpeg" alt="一键秀"></p>
|
||||
<p> 一键秀(一键生成)已部署使用 YApi </p>
|
||||
<p> 一键秀(一键生成)已部署使用 YApi </p>
|
||||
</li><li><p><img src="./images/yonyou.jpg" alt="用友"></p>
|
||||
<p> 用友已经部署使用YApi并且自己开发了单点登录插件 </p>
|
||||
</li></ul>
|
||||
|
||||
</article>
|
||||
|
@ -178,9 +178,9 @@
|
||||
<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>
|
||||
<li>mongodb 自动备份脚本</li></ul>
|
||||
<li>数据导入同步</li></ul>
|
||||
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
|
||||
<li>修复离开接口编辑页面的 confirm 框有时候会触发两次 & confirm 的 ‘X’ 按钮无效</li><li>修复添加集合后测试集合list不更新问题</li></ul>
|
||||
<li>修复离开接口编辑页面的 confirm 框有时候会触发两次 & confirm 的 ‘X’ 按钮无效</li><li>修复添加集合后测试集合list不更新问题</li><li>测试集合点击对应接口侧边栏不切换</li><li>测试集合处,点击删除不成功</li><li>修改编辑接口后,再回到测试集合处数据不更新问题</li></ul>
|
||||
<h3 class="subject" id="v1.3.4">v1.3.4 <a class="hashlink" href="#v1.3.4">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
|
||||
<li>进入project页面加入loading</li><li>接口list页table中加入分页</li><li>项目添加者自动变成项目组长</li></ul>
|
||||
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
|
||||
|
@ -606,7 +606,7 @@ class interfaceColController extends baseController {
|
||||
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.interface_up_time = data.up_time;
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 400, e.message)
|
||||
|
@ -158,7 +158,7 @@ class projectController extends baseController {
|
||||
}
|
||||
|
||||
|
||||
let checkRepeat = await this.Model.checkNameRepeat(params.name,params.group_id);
|
||||
let checkRepeat = await this.Model.checkNameRepeat(params.name, params.group_id);
|
||||
|
||||
if (checkRepeat > 0) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的项目名');
|
||||
|
Loading…
Reference in New Issue
Block a user