fix(接口测试): 修复Mock-json格式错误时不报JSON错误

This commit is contained in:
RubyLiu 2023-07-27 11:03:44 +08:00 committed by rubylliu
parent 0b6210d9e4
commit aef1c260d0
1 changed files with 8 additions and 2 deletions

View File

@ -196,8 +196,14 @@ export default {
const MsConvert = new Convert();
if (this.body.format === 'JSON-SCHEMA') {
if (this.body.raw && !this.body.jsonSchema) {
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
if (this.body.raw) {
try {
const jsonObj = JSON.parse(this.body.raw)
this.body.jsonSchema = MsConvert.format(jsonObj);
} catch (e) {
this.body.format = 'JSON';
this.$message.error(this.$t('api_definition.body.json_format_error'));
}
}
} else {
if (this.body.jsonSchema) {