From 72abd2100bf4713f498c85e2409688aaec75e6c9 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 21 Feb 2022 15:19:09 +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=8Dmock=E5=93=8D=E5=BA=94=E8=B7=9F=E9=9A=8FAPI?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=90=8E=E5=86=8D=E5=88=87=E6=8D=A2raw?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=EF=BC=8C=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E4=BD=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1010364 --user=宋天阳 【接口测试】mock响应跟随API定义后再切换raw格式,无法编辑响应体 https://www.tapd.cn/55049933/s/1106633 --- .../api/definition/components/EditCompleteContainer.vue | 2 +- .../components/mock/Components/MockApiResponseBody.vue | 3 ++- .../components/mock/Components/MockApiScriptEditor.vue | 2 +- .../components/mock/Components/MockResponseParam.vue | 2 +- .../components/api/definition/components/mock/MockTab.vue | 3 ++- .../src/business/components/common/components/MsCodeEdit.vue | 2 ++ 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue b/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue index bfacaeedb6..67432a38a5 100644 --- a/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue +++ b/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue @@ -81,7 +81,7 @@
-
diff --git a/frontend/src/business/components/api/definition/components/mock/Components/MockApiResponseBody.vue b/frontend/src/business/components/api/definition/components/mock/Components/MockApiResponseBody.vue index ec0bf7cd58..1360edaf0c 100644 --- a/frontend/src/business/components/api/definition/components/mock/Components/MockApiResponseBody.vue +++ b/frontend/src/business/components/api/definition/components/mock/Components/MockApiResponseBody.vue @@ -61,6 +61,7 @@ :read-only="isReadOnly" :data.sync="body.raw" :modes="modes" + v-if="loadIsOver" height="90%" ref="codeEdit"/>
@@ -257,7 +258,7 @@ export default { let selectUrl = "/mockConfig/getApiResponse/" + this.apiId; this.$get(selectUrl, response => { let apiResponse = response.data; - if (apiResponse && apiResponse.returnMsg) { + if (apiResponse && apiResponse.returnData) { this.body.apiRspRaw = apiResponse.returnData; } this.refreshMsCodeEdit(); diff --git a/frontend/src/business/components/api/definition/components/mock/Components/MockApiScriptEditor.vue b/frontend/src/business/components/api/definition/components/mock/Components/MockApiScriptEditor.vue index a380dbdf14..f1ac3e428e 100644 --- a/frontend/src/business/components/api/definition/components/mock/Components/MockApiScriptEditor.vue +++ b/frontend/src/business/components/api/definition/components/mock/Components/MockApiScriptEditor.vue @@ -179,7 +179,7 @@ export default { if (laguanges === "python") { returnScript = 'param=vars["body.${param}"]'; } else { - returnScript = 'var param=vars.get(body.${param}")\n' + + returnScript = 'var param=vars.get(body.${param}");\n' + '//如果对象是多层JSON,需要引入fastjson协助解析:\n' + '// 以"{\"name\":\"user\",\"rows\":[{\"type\":1}]}" 为demo,取rows第1个的type数据:\n' + 'import com.alibaba.fastjson.JSON;\n' + diff --git a/frontend/src/business/components/api/definition/components/mock/Components/MockResponseParam.vue b/frontend/src/business/components/api/definition/components/mock/Components/MockResponseParam.vue index 2b53ef10e7..457ee7fe5b 100644 --- a/frontend/src/business/components/api/definition/components/mock/Components/MockResponseParam.vue +++ b/frontend/src/business/components/api/definition/components/mock/Components/MockResponseParam.vue @@ -36,7 +36,7 @@ -
+

{{ $t('api_test.definition.request.post_script') }}

diff --git a/frontend/src/business/components/api/definition/components/mock/MockTab.vue b/frontend/src/business/components/api/definition/components/mock/MockTab.vue index 54ae81d200..d7b8595cbb 100644 --- a/frontend/src/business/components/api/definition/components/mock/MockTab.vue +++ b/frontend/src/business/components/api/definition/components/mock/MockTab.vue @@ -2,7 +2,7 @@
- {{ $t('project.version.name') }}: {{ mockConfigData.versionName }} + {{ $t('project.version.name') }}: {{ versionName }}