fix(接口测试): 修复接口定义文档中raw响应体不展示的问题

--bug=1019556 --user=宋天阳 【接口测试】接口定义-文档中的响应体没显示
https://www.tapd.cn/55049933/s/1301054
This commit is contained in:
song-tianyang 2022-11-22 14:44:06 +08:00 committed by 建国
parent 0fd341b790
commit 61d3bd0019
3 changed files with 13 additions and 6 deletions

View File

@ -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;

View File

@ -4,7 +4,7 @@
<el-popover v-if="projectId" placement="right" width="260" @show="shareApiDocument('false')">
<p>{{ shareUrl }}</p>
<div style="text-align: right; margin: 0">
<el-button type="primary" size="mini" v-clipboard:copy="shareUrl">{{ $t('commons.copy') }} </el-button>
<el-button type="primary" size="mini" v-clipboard:copy="shareUrl">{{ $t('commons.copy') }}</el-button>
</div>
<i class="el-icon-share" slot="reference" style="margin-right: 10px; cursor: pointer"></i>
</el-popover>
@ -36,7 +36,7 @@
<el-col :span="6">{{ $t('api_test.definition.request.responsible') }} : {{ apiInfo.responsibler }}</el-col>
<el-col :span="6">{{ $t('commons.create_user') }} : {{ apiInfo.createUser }}</el-col>
</el-row>
<el-row style="margin-top: 10px"> {{ $t('commons.description') }} : {{ apiInfo.desc }} </el-row>
<el-row style="margin-top: 10px"> {{ $t('commons.description') }} : {{ apiInfo.desc }}</el-row>
</div>
</el-row>
<!--api请求头-->
@ -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);
//

View File

@ -52,7 +52,7 @@
<br />
<p
style="margin: 0px 20px"
v-html="formatRowData(apiInfo.responseBodyParamType, apiInfo.requestBodyStructureData)"></p>
v-html="formatRowData(apiInfo.responseBodyParamType, apiInfo.responseBodyStructureData)"></p>
<br />
</div>
</div>