diff --git a/api-test/frontend/src/business/definition/components/mock/Components/MockApiBody.vue b/api-test/frontend/src/business/definition/components/mock/Components/MockApiBody.vue index 87ce8acaf5..a859f193ef 100644 --- a/api-test/frontend/src/business/definition/components/mock/Components/MockApiBody.vue +++ b/api-test/frontend/src/business/definition/components/mock/Components/MockApiBody.vue @@ -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) {