mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-31 14:50:26 +08:00
fix: 优化插件【Swagger 自动同步】在添加地址时的服务端校验行为
This commit is contained in:
parent
1b25ff4e55
commit
141f8bedfb
@ -12,9 +12,9 @@ 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 url = require('url');
|
||||
const {getToken} = require('../utils/token')
|
||||
const sha = require('sha.js');
|
||||
const axios = require('axios').default;
|
||||
|
||||
class projectController extends baseController {
|
||||
constructor(ctx) {
|
||||
@ -1119,15 +1119,17 @@ class projectController extends baseController {
|
||||
return (ctx.body = yapi.commons.resReturn(queryList, 0, 'ok'));
|
||||
}
|
||||
|
||||
// 输入 swagger url 的时候node端请求数据
|
||||
// 输入 swagger url 的时候 node 端请求数据
|
||||
async swaggerUrl(ctx) {
|
||||
try {
|
||||
let ops = url.parse(ctx.request.query.url);
|
||||
let result = await yapi.commons.createWebAPIRequest(ops);
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
const { url } = ctx.request.query;
|
||||
const { data } = await axios.get(url);
|
||||
if (data == null || typeof data !== 'object') {
|
||||
throw new Error('返回数据格式不是 JSON');
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(data);
|
||||
} catch (err) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
ctx.body = yapi.commons.resReturn(null, 402, String(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user