From 9c4e5bfbdb3acfe5352215605b0e60d4e603bb2a Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 31 Dec 2020 18:49:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20json=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/common/json-schema/JsonEditor.vue | 8 ++++---- .../common/json-schema/schema/json-schema-editor/main.vue | 3 ++- .../json-schema/schema/json-schema-editor/mock/index.vue | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/business/components/common/json-schema/JsonEditor.vue b/frontend/src/business/components/common/json-schema/JsonEditor.vue index f9225be0d1..b0dd0eb481 100644 --- a/frontend/src/business/components/common/json-schema/JsonEditor.vue +++ b/frontend/src/business/components/common/json-schema/JsonEditor.vue @@ -34,12 +34,12 @@ created() { if (!this.body.jsonSchema && this.body.raw) { let obj = {"root": GenerateSchema(JSON.parse(this.body.raw))} - this.body.jsonSchema = obj; - this.schema = this.body.jsonSchema; + this.schema = obj; } else if (this.body.jsonSchema) { - this.schema = this.body.jsonSchema; + this.schema = {"root": this.body.jsonSchema}; } + this.body.jsonSchema = this.schema.root; }, data() { return { @@ -57,7 +57,7 @@ methods: { handleClick() { if (this.activeName === 'preview') { - this.preview = schemaToJson(Object.values(this.schema)[0]); + this.preview = schemaToJson(this.schema.root); } }, openOneClickOperation() { diff --git a/frontend/src/business/components/common/json-schema/schema/json-schema-editor/main.vue b/frontend/src/business/components/common/json-schema/schema/json-schema-editor/main.vue index 2d2497c6c9..bc55e434e3 100644 --- a/frontend/src/business/components/common/json-schema/schema/json-schema-editor/main.vue +++ b/frontend/src/business/components/common/json-schema/schema/json-schema-editor/main.vue @@ -21,7 +21,7 @@ - + @@ -220,6 +220,7 @@ this.$delete(this.pickValue, 'properties') this.$delete(this.pickValue, 'items') this.$delete(this.pickValue, 'required') + this.$delete(this.pickValue, 'mock') if (this.isArray) { this.$set(this.pickValue, 'items', {type: 'string', mock: {mock: ""}}) } diff --git a/frontend/src/business/components/common/json-schema/schema/json-schema-editor/mock/index.vue b/frontend/src/business/components/common/json-schema/schema/json-schema-editor/mock/index.vue index 282d4a9ce5..a391649f4c 100644 --- a/frontend/src/business/components/common/json-schema/schema/json-schema-editor/mock/index.vue +++ b/frontend/src/business/components/common/json-schema/schema/json-schema-editor/mock/index.vue @@ -2,10 +2,10 @@
{ } }, + disabled: Boolean, }, data() { return { @@ -43,6 +44,9 @@ } else { this.schema.mock = this.mock; } + if (this.schema.type === 'object') { + this.$delete(this.schema, 'mock') + } }, mounted() { },