mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-24 15:30:44 +08:00
fix: swagger 解析去掉重复的json Parse
This commit is contained in:
parent
a7fbac672d
commit
0e415b495c
@ -31,7 +31,6 @@ const RadioGroup = Radio.Group;
|
|||||||
const importDataModule = {};
|
const importDataModule = {};
|
||||||
const exportDataModule = {};
|
const exportDataModule = {};
|
||||||
const HandleImportData = require('common/HandleImportData');
|
const HandleImportData = require('common/HandleImportData');
|
||||||
import {json5_parse} from '../../../../common.js'
|
|
||||||
function handleExportRouteParams(url, status, isWiki) {
|
function handleExportRouteParams(url, status, isWiki) {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
return;
|
return;
|
||||||
@ -258,8 +257,8 @@ class ProjectData extends Component {
|
|||||||
try {
|
try {
|
||||||
// 处理swagger url 导入
|
// 处理swagger url 导入
|
||||||
await this.props.handleSwaggerUrlData(this.state.swaggerUrl);
|
await this.props.handleSwaggerUrlData(this.state.swaggerUrl);
|
||||||
let result = json5_parse(this.props.swaggerUrlData)
|
// let result = json5_parse(this.props.swaggerUrlData)
|
||||||
let res = await importDataModule[this.state.curImportType].run(result);
|
let res = await importDataModule[this.state.curImportType].run(this.props.swaggerUrlData);
|
||||||
if (this.state.dataSync === 'merge') {
|
if (this.state.dataSync === 'merge') {
|
||||||
// merge
|
// merge
|
||||||
this.showConfirm(res);
|
this.showConfirm(res);
|
||||||
|
@ -65,7 +65,11 @@ const swagger = require('swagger-client');
|
|||||||
async function run(res) {
|
async function run(res) {
|
||||||
let interfaceData = { apis: [], cats: [] };
|
let interfaceData = { apis: [], cats: [] };
|
||||||
if(typeof res === 'string' && res){
|
if(typeof res === 'string' && res){
|
||||||
res = JSON.parse(res);
|
try{
|
||||||
|
res = JSON.parse(res);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('json 解析出错',e.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isOAS3 = res.openapi && res.openapi === '3.0.0';
|
isOAS3 = res.openapi && res.openapi === '3.0.0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user