From 9b106c7087549905f8b50aae1fb889caed981908 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 22 Nov 2022 14:44:06 +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=8D=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E4=B8=ADraw=E5=93=8D=E5=BA=94=E4=BD=93=E4=B8=8D?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=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=1019556 --user=宋天阳 【接口测试】接口定义-文档中的响应体没显示 https://www.tapd.cn/55049933/s/1301054 --- .../java/io/metersphere/service/ShareInfoService.java | 7 ++++++- .../components/document/components/ApiInformation.vue | 10 ++++++---- .../components/document/components/ApiResponseInfo.vue | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/ShareInfoService.java b/api-test/backend/src/main/java/io/metersphere/service/ShareInfoService.java index 949f08c8a1..2a00708dda 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ShareInfoService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ShareInfoService.java @@ -384,7 +384,12 @@ public class ShareInfoService extends BaseShareInfoService { } else { apiInfoDTO.setResponseBodyParamType(type); } - if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) { + if (StringUtils.equalsIgnoreCase(type, "Raw")) { + if (bodyObj.has("raw")) { + String raw = bodyObj.get("raw").asText(); + apiInfoDTO.setResponseBodyStructureData(raw); + } + } else if (StringUtils.equalsAny(type, "JSON", "XML")) { //判断是否是JsonSchema boolean isJsonSchema = false; diff --git a/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue b/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue index d5eb3edfea..5009e093ba 100644 --- a/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue +++ b/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue @@ -4,7 +4,7 @@

{{ shareUrl }}

- {{ $t('commons.copy') }} + {{ $t('commons.copy') }}
@@ -36,7 +36,7 @@ {{ $t('api_test.definition.request.responsible') }} : {{ apiInfo.responsibler }} {{ $t('commons.create_user') }} : {{ apiInfo.createUser }} - {{ $t('commons.description') }} : {{ apiInfo.desc }} + {{ $t('commons.description') }} : {{ apiInfo.desc }} @@ -102,7 +102,7 @@ import MsCodeEdit from 'metersphere-frontend/src/components/MsCodeEdit'; import ApiStatus from '@/business/definition/components/list/ApiStatus'; import MsJsonCodeEdit from '@/business/commons/json-schema/JsonSchemaEditor'; import ApiRemarkShow from '@/business/definition/components/document/components/ApiRemarkShow'; -import { generateApiDocumentShareInfo, documentShareUrl } from '@/api/share'; +import { documentShareUrl, generateApiDocumentShareInfo } from '@/api/share'; import ApiInfoCollapse from '@/business/definition/components/document/components/ApiInfoCollapse'; import ApiRequestInfo from '@/business/definition/components/document/components/ApiRequestInfo'; import ApiResponseInfo from '@/business/definition/components/document/components/ApiResponseInfo'; @@ -210,7 +210,9 @@ export default { hasResponseBody(apiInfo) { let hasParams = false; if (apiInfo) { - if (this.formParamTypes.includes(apiInfo.responseBodyParamType)) { + if (apiInfo.responseBodyParamType === 'Raw') { + hasParams = true; + } else if (this.formParamTypes.includes(apiInfo.responseBodyParamType)) { if (apiInfo.responseBodyFormData && apiInfo.responseBodyFormData !== '无') { let jsonArr = JSON.parse(apiInfo.responseBodyFormData); //遍历,把必填项空的数据去掉 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 5fb87c4eaf..e990885535 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 @@ -52,7 +52,7 @@

+ v-html="formatRowData(apiInfo.responseBodyParamType, apiInfo.responseBodyStructureData)">