fix(接口定义): JSON-SCHEMA转换问题修复

This commit is contained in:
fit2-zhao 2021-01-18 13:31:52 +08:00
parent c1303bd8a8
commit 20f7e727ea
3 changed files with 9 additions and 3 deletions

View File

@ -31,7 +31,7 @@
body: {},
},
created() {
if (!this.body.jsonSchema && this.body.raw) {
if (!this.body.jsonSchema && this.body.raw && this.checkIsJson(this.body.raw)) {
let obj = {"root": GenerateSchema(JSON.parse(this.body.raw))}
this.schema = obj;
}
@ -70,6 +70,14 @@
openOneClickOperation() {
this.$refs.importJson.openOneClickOperation();
},
checkIsJson(json) {
try {
JSON.parse(json);
return true;
} catch (e) {
return false;
}
},
jsonData(data) {
let obj = {"root": data}
this.schema = obj;

View File

@ -61,7 +61,6 @@
json5.parse(json);
return true;
} catch (e) {
alert(1);
return false;
}
},

View File

@ -289,7 +289,6 @@
for (const k in this.advancedValue) {
if (this.pickValue[k]) this.advancedValue[k] = this.pickValue[k]
}
console.log(this.pickValue)
},
handleClose() {
this.modalVisible = false;