From 4d4826f7c35d65075bf8ffa4fc179a35601490d3 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 6 Dec 2022 14:50:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DjsonSchema=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020682 --user=王孝刚 【接口测试】新建接口-请求参数-请求体选择json-未开启schema-保存接口-查看接口文档-响应体显示请求体的数据 https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001020682 --bug=1020664 --user=王孝刚 【接口测试】编辑接口-开启json-schema-数据不显示了 https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001020664 --- .../src/business/definition/components/body/ApiBody.vue | 3 +++ .../components/document/components/ApiResponseInfo.vue | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api-test/frontend/src/business/definition/components/body/ApiBody.vue b/api-test/frontend/src/business/definition/components/body/ApiBody.vue index 8ea402f390..9f2bd070cc 100644 --- a/api-test/frontend/src/business/definition/components/body/ApiBody.vue +++ b/api-test/frontend/src/business/definition/components/body/ApiBody.vue @@ -246,6 +246,9 @@ export default { this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw)); } else { let data = MsConvert.format(JSON.parse(this.body.raw)); + if (!this.body.jsonSchema.type) { + this.body.jsonSchema.type = data.type; + } this.body.jsonSchema = this.deepAssign(this.body.jsonSchema, data); } } catch (e) { diff --git a/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue b/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue index e990885535..8e892783fb 100644 --- a/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue +++ b/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue @@ -122,10 +122,10 @@ export default { } catch (e) { return false; } - } else if (jsonType === 'response' && api.requestBodyStructureData) { + } else if (jsonType === 'response' && api.responseBodyStructureData) { try { - JSON.parse(api.requestBodyStructureData); - api.responseJsonSchema = { raw: api.requestBodyStructureData }; + JSON.parse(api.responseBodyStructureData); + api.responseJsonSchema = { raw: api.responseBodyStructureData }; return true; } catch (e) { return false;