Merge remote-tracking branch 'origin/v1.8' into v1.8

This commit is contained in:
wenyann 2021-03-29 18:30:42 +08:00
commit d7113c4c0c
17 changed files with 166 additions and 48 deletions

View File

@ -29,6 +29,7 @@ public class EsbDataStruct {
private boolean required; private boolean required;
private String description; private String description;
private List<EsbDataStruct> children; private List<EsbDataStruct> children;
private String status = "";
public void init(){ public void init(){
this.uuid = UUID.randomUUID().toString(); this.uuid = UUID.randomUUID().toString();
@ -127,6 +128,9 @@ public class EsbDataStruct {
if (element != null) { if (element != null) {
if (this.children == null || this.children.isEmpty()) { if (this.children == null || this.children.isEmpty()) {
if(this.value == null ){
this.value = "";
}
element.addText(this.value); element.addText(this.value);
} else { } else {
for (EsbDataStruct child : children) { for (EsbDataStruct child : children) {

View File

@ -114,23 +114,26 @@ public class MsScenario extends MsTestElement {
// 设置共享cookie // 设置共享cookie
config.setEnableCookieShare(enableCookieShare); config.setEnableCookieShare(enableCookieShare);
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16); Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
// 兼容历史数据 if (config.getConfig() == null) {
if (environmentMap == null || environmentMap.isEmpty()) { // 兼容历史数据
environmentMap = new HashMap<>(16); if (this.environmentMap == null || this.environmentMap.isEmpty()) {
if (StringUtils.isNotBlank(environmentId)) { this.environmentMap = new HashMap<>(16);
environmentMap.put(SessionUtils.getCurrentProjectId(), environmentId); if (StringUtils.isNotBlank(environmentId)) {
} // 兼容1.8之前 没有environmentMap但有environmentId的数据
} this.environmentMap.put("historyProjectID", environmentId);
if (environmentMap != null && !environmentMap.isEmpty()) {
environmentMap.keySet().forEach(projectId -> {
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentMap.get(projectId));
if (environment != null && environment.getConfig() != null) {
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
envConfig.put(projectId, env);
} }
}); }
config.setConfig(envConfig); if (this.environmentMap != null && !this.environmentMap.isEmpty()) {
this.environmentMap.keySet().forEach(projectId -> {
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
ApiTestEnvironmentWithBLOBs environment = environmentService.get(this.environmentMap.get(projectId));
if (environment != null && environment.getConfig() != null) {
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
envConfig.put(projectId, env);
}
});
config.setConfig(envConfig);
}
} }
if (CollectionUtils.isNotEmpty(this.getVariables())) { if (CollectionUtils.isNotEmpty(this.getVariables())) {
config.setVariables(this.variables); config.setVariables(this.variables);

View File

@ -129,6 +129,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
config.setConfig(getEnvironmentConfig(useEnvironment)); config.setConfig(getEnvironmentConfig(useEnvironment));
} }
// 1.8 之前历史数据
if(StringUtils.isEmpty(this.getProjectId()) && config.getConfig()!= null && !config.getConfig().isEmpty()){
this.setProjectId("historyProjectID");
}
// 添加环境中的公共变量 // 添加环境中的公共变量
Arguments arguments = this.addArguments(config); Arguments arguments = this.addArguments(config);
if (arguments != null) { if (arguments != null) {

View File

@ -2,6 +2,7 @@ package io.metersphere.api.dto.definition.request.sampler;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson.annotation.JSONType;
import io.metersphere.api.dto.automation.EsbDataStruct;
import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.MsTestElement;
import io.metersphere.api.dto.definition.request.ParameterConfig; import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor; import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
@ -70,6 +71,12 @@ public class MsTCPSampler extends MsTestElement {
@JSONField(ordinal = 39) @JSONField(ordinal = 39)
private String projectId; private String projectId;
/**
* 新加两个参数场景保存/修改时需要的参数不会传递JMeter只是用于最后的保留
*/
private List<EsbDataStruct> esbDataStruct;
private List<EsbDataStruct> backEsbDataStruct;
@Override @Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) { public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
// 非导出操作且不是启用状态则跳过执行 // 非导出操作且不是启用状态则跳过执行

View File

@ -90,6 +90,8 @@ public class ApiAutomationService {
@Resource @Resource
@Lazy @Lazy
private TestPlanScenarioCaseService testPlanScenarioCaseService; private TestPlanScenarioCaseService testPlanScenarioCaseService;
@Resource
private EsbApiParamService esbApiParamService;
public List<ApiScenarioDTO> list(ApiScenarioRequest request) { public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
request = this.initRequest(request, true, true); request = this.initRequest(request, true, true);
@ -184,6 +186,9 @@ public class ApiAutomationService {
scenario.setCreateTime(System.currentTimeMillis()); scenario.setCreateTime(System.currentTimeMillis());
scenario.setNum(getNextNum(request.getProjectId())); scenario.setNum(getNextNum(request.getProjectId()));
//检查场景的请求步骤如果含有ESB请求步骤的话要做参数计算处理
esbApiParamService.checkScenarioRequests(request);
apiScenarioMapper.insert(scenario); apiScenarioMapper.insert(scenario);
List<String> bodyUploadIds = request.getBodyUploadIds(); List<String> bodyUploadIds = request.getBodyUploadIds();
@ -205,6 +210,9 @@ public class ApiAutomationService {
List<String> bodyUploadIds = request.getBodyUploadIds(); List<String> bodyUploadIds = request.getBodyUploadIds();
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
//检查场景的请求步骤如果含有ESB请求步骤的话要做参数计算处理
esbApiParamService.checkScenarioRequests(request);
final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); final ApiScenarioWithBLOBs scenario = buildSaveScenario(request);
apiScenarioMapper.updateByPrimaryKeySelective(scenario); apiScenarioMapper.updateByPrimaryKeySelective(scenario);
extScheduleMapper.updateNameByResourceID(request.getId(), request.getName());// 修改场景name同步到修改首页定时任务 extScheduleMapper.updateNameByResourceID(request.getId(), request.getName());// 修改场景name同步到修改首页定时任务

View File

@ -3,11 +3,13 @@ package io.metersphere.api.service;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.metersphere.api.dto.automation.EsbDataStruct; import io.metersphere.api.dto.automation.EsbDataStruct;
import io.metersphere.api.dto.automation.SaveApiScenarioRequest;
import io.metersphere.api.dto.automation.parse.EsbDataParser; import io.metersphere.api.dto.automation.parse.EsbDataParser;
import io.metersphere.api.dto.definition.ApiDefinitionResult; import io.metersphere.api.dto.definition.ApiDefinitionResult;
import io.metersphere.api.dto.definition.ApiTestCaseResult; import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.api.dto.definition.SaveApiDefinitionRequest; import io.metersphere.api.dto.definition.SaveApiDefinitionRequest;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest; import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.dto.definition.request.MsTestElement;
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler; import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
@ -313,6 +315,35 @@ public class EsbApiParamService {
return keyValueList; return keyValueList;
} }
private List<KeyValue> genKeyValueListByDataStruct(MsTCPSampler tcpSampler, List<EsbDataStruct> dataStructRequestList) {
List<KeyValue> keyValueList = new ArrayList<>();
String sendRequest = tcpSampler.getRequest();
String paramRegexStr = "\\$\\{([^}]*)\\}";
try {
if (StringUtils.isNotEmpty(sendRequest)) {
List<String> paramList = new ArrayList<>();
Pattern regex = Pattern.compile(paramRegexStr);
Matcher matcher = regex.matcher(sendRequest);
while (matcher.find()) {
paramList.add(matcher.group(1));
}
for (String param : paramList) {
String value = this.genValueFromEsbDataStructByParam(dataStructRequestList, param);
if (StringUtils.isNotEmpty(value)) {
KeyValue kv = new KeyValue();
kv.setName(param);
kv.setValue(value);
kv.setRequired(true);
keyValueList.add(kv);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return keyValueList;
}
//通过报文模版中的变量参数解析报文数据结构生成对应的xml数据 //通过报文模版中的变量参数解析报文数据结构生成对应的xml数据
private String genValueFromEsbDataStructByParam(List<EsbDataStruct> dataStructRequestList, String param) { private String genValueFromEsbDataStructByParam(List<EsbDataStruct> dataStructRequestList, String param) {
String returnValue = ""; String returnValue = "";
@ -341,10 +372,32 @@ public class EsbApiParamService {
return request; return request;
} }
public void handleEsbRequest(MsTCPSampler tcpSampler) {
try {
//修改reqeust.parameters, 将树结构类型数据转化为表格类型数据供执行时参数的提取
if (tcpSampler.getEsbDataStruct() != null ) {
List<KeyValue> keyValueList = this.genKeyValueListByDataStruct(tcpSampler, tcpSampler.getEsbDataStruct());
tcpSampler.setParameters(keyValueList);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void deleteByResourceIdIn(List<String> apiIds) { public void deleteByResourceIdIn(List<String> apiIds) {
EsbApiParamsExample example = new EsbApiParamsExample(); EsbApiParamsExample example = new EsbApiParamsExample();
example.createCriteria().andResourceIdIn(apiIds); example.createCriteria().andResourceIdIn(apiIds);
esbApiParamsMapper.deleteByExample(example); esbApiParamsMapper.deleteByExample(example);
} }
public void checkScenarioRequests(SaveApiScenarioRequest request) {
if(request.getScenarioDefinition() != null ){
List<MsTestElement> hashTreeList = request.getScenarioDefinition().getHashTree();
for (MsTestElement testElement :hashTreeList) {
if(testElement instanceof MsTCPSampler){
this.handleEsbRequest((MsTCPSampler)testElement);
}
}
}
}
} }

View File

@ -76,12 +76,17 @@ public class HistoricalDataUpgradeService {
return scenario; return scenario;
} }
private MsScenario createScenario(Scenario oldScenario) { private MsScenario createScenario(Scenario oldScenario, String projectId) {
MsScenario scenario = new MsScenario(); MsScenario scenario = new MsScenario();
scenario.setOldVariables(oldScenario.getVariables()); scenario.setOldVariables(oldScenario.getVariables());
scenario.setName(oldScenario.getName()); scenario.setName(oldScenario.getName());
scenario.setEnableCookieShare(oldScenario.isEnableCookieShare()); scenario.setEnableCookieShare(oldScenario.isEnableCookieShare());
scenario.setEnvironmentId(oldScenario.getEnvironmentId()); scenario.setEnvironmentId(oldScenario.getEnvironmentId());
if (StringUtils.isNotEmpty(oldScenario.getEnvironmentId())) {
HashMap<String, String> envMap = new HashMap<>();
envMap.put(projectId, oldScenario.getEnvironmentId());
scenario.setEnvironmentMap(envMap);
}
scenario.setReferenced("Upgrade"); scenario.setReferenced("Upgrade");
scenario.setId(oldScenario.getId()); scenario.setId(oldScenario.getId());
scenario.setResourceId(UUID.randomUUID().toString()); scenario.setResourceId(UUID.randomUUID().toString());
@ -397,6 +402,7 @@ public class HistoricalDataUpgradeService {
MsScenario scenarioTest = createScenarioByTest(test); MsScenario scenarioTest = createScenarioByTest(test);
LinkedList<MsTestElement> listSteps = new LinkedList<>(); LinkedList<MsTestElement> listSteps = new LinkedList<>();
List<Scenario> scenarios = JSON.parseArray(test.getScenarioDefinition(), Scenario.class); List<Scenario> scenarios = JSON.parseArray(test.getScenarioDefinition(), Scenario.class);
String envId = null;
if (CollectionUtils.isNotEmpty(scenarios)) { if (CollectionUtils.isNotEmpty(scenarios)) {
// 批量处理 // 批量处理
for (Scenario scenario : scenarios) { for (Scenario scenario : scenarios) {
@ -405,7 +411,7 @@ public class HistoricalDataUpgradeService {
} }
scenario.setId(test.getId() + "=" + scenario.getId()); scenario.setId(test.getId() + "=" + scenario.getId());
scenario.setName(test.getName() + "_" + scenario.getName()); scenario.setName(test.getName() + "_" + scenario.getName());
MsScenario scenario1 = createScenario(scenario); MsScenario scenario1 = createScenario(scenario, saveHistoricalDataUpgrade.getProjectId());
String scenarioDefinition = JSON.toJSONString(scenario1); String scenarioDefinition = JSON.toJSONString(scenario1);
num++; num++;
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenario.getId(), scenario.getName(), scenario.getRequests().size(), scenarioDefinition, mapper, num); createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenario.getId(), scenario.getName(), scenario.getRequests().size(), scenarioDefinition, mapper, num);
@ -417,10 +423,20 @@ public class HistoricalDataUpgradeService {
step.setResourceId(UUID.randomUUID().toString()); step.setResourceId(UUID.randomUUID().toString());
step.setReferenced("REF"); step.setReferenced("REF");
listSteps.add(step); listSteps.add(step);
if (StringUtils.isNotEmpty(scenario.getEnvironmentId())) {
envId = scenario.getEnvironmentId();
}
} }
} }
num++; num++;
scenarioTest.setHashTree(listSteps); scenarioTest.setHashTree(listSteps);
if (StringUtils.isNotEmpty(envId)) {
HashMap<String, String> envMap = new HashMap<>();
envMap.put(saveHistoricalDataUpgrade.getProjectId(), envId);
scenarioTest.setEnvironmentMap(envMap);
scenarioTest.setEnvironmentId(envId);
}
String scenarioDefinition = JSON.toJSONString(scenarioTest); String scenarioDefinition = JSON.toJSONString(scenarioTest);
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenarioTest.getId(), scenarioTest.getName(), listSteps.size(), scenarioDefinition, mapper, num); createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenarioTest.getId(), scenarioTest.getName(), listSteps.size(), scenarioDefinition, mapper, num);
} }

View File

@ -67,7 +67,7 @@
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer"; import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList"; import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
import {getUUID, downloadFile, checkoutTestManagerOrTestUser} from "@/common/js/utils"; import {getUUID, downloadFile, checkoutTestManagerOrTestUser,getCurrentUser} from "@/common/js/utils";
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule"; import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
import MsEditApiScenario from "./scenario/EditApiScenario"; import MsEditApiScenario from "./scenario/EditApiScenario";
@ -189,6 +189,7 @@
let name = getUUID().substring(0, 8); let name = getUUID().substring(0, 8);
this.activeName = name; this.activeName = name;
let currentScenario = { let currentScenario = {
status: "Underway", principal: getCurrentUser().id,
apiScenarioModuleId: "root", id: getUUID(), apiScenarioModuleId: "root", id: getUUID(),
modulePath: "/" + this.$t("commons.module_title") modulePath: "/" + this.$t("commons.module_title")
}; };

View File

@ -101,25 +101,25 @@ export default {
let requestObj = JSON.parse(item.request); let requestObj = JSON.parse(item.request);
if(requestObj.esbDataStruct != null ){ if(requestObj.esbDataStruct != null ){
//ESB // //ESB
let param = {}; // let param = {};
param.request = requestObj; // param.request = requestObj;
param.method = "ESB"; // param.method = "ESB";
param.esbDataStruct = JSON.stringify(requestObj.esbDataStruct); // param.esbDataStruct = JSON.stringify(requestObj.esbDataStruct);
if(requestObj.backEsbDataStruct != null){ // if(requestObj.backEsbDataStruct != null){
param.backEsbDataStruct = JSON.stringify(requestObj.backEsbDataStruct); // param.backEsbDataStruct = JSON.stringify(requestObj.backEsbDataStruct);
}else{ // }else{
param.backEsbDataStruct = ""; // param.backEsbDataStruct = "";
} // }
this.$post("/api/definition/updateEsbRequest", param, response => { // this.$post("/api/definition/updateEsbRequest", param, response => {
if(response.data!=null){ // if(response.data!=null){
if(response.data.request!=null){ // if(response.data.request!=null){
item.request = JSON.stringify(response.data.request); // item.request = JSON.stringify(response.data.request);
param.method = "TCP"; // param.method = "TCP";
} // }
} // }
}) // })
} }
}); });
this.$emit('save', apiCases, 'CASE', reference); this.$emit('save', apiCases, 'CASE', reference);

View File

@ -28,9 +28,12 @@
<div class="header-right" @click.stop> <div class="header-right" @click.stop>
<slot name="message"></slot> <slot name="message"></slot>
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn"> <el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn">
<el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled && !data.root"/> <el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled && !data.root" style="width: 30px"/>
</el-tooltip> </el-tooltip>
<slot name="button"></slot> <slot name="button"></slot>
<el-tooltip content="Copy" placement="top">
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="padding: 5px"/>
</el-tooltip>
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/> <step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/>
</div> </div>

View File

@ -23,7 +23,7 @@
<template v-slot:button> <template v-slot:button>
<el-tooltip :content="$t('api_test.run')" placement="top"> <el-tooltip :content="$t('api_test.run')" placement="top">
<el-button @click="run" icon="el-icon-video-play" class="ms-btn" size="mini" circle/> <el-button @click="run" icon="el-icon-video-play" style="padding: 5px" class="ms-btn" size="mini" circle/>
</el-tooltip> </el-tooltip>
</template> </template>
@ -289,6 +289,9 @@
}, },
active(item) { active(item) {
this.request.active = !this.request.active; this.request.active = !this.request.active;
if (this.node) {
this.node.expanded = this.request.active;
}
this.reload(); this.reload();
}, },
run() { run() {

View File

@ -105,11 +105,11 @@
remove() { remove() {
this.$emit('remove', this.scenario, this.node); this.$emit('remove', this.scenario, this.node);
}, },
active(item) { active() {
if (item && item.active) { if (this.node) {
item.active = !item.active; this.node.expanded = !this.node.expanded;
}
this.reload(); this.reload();
}
}, },
copyRow() { copyRow() {
this.$emit('copyRow', this.scenario, this.node); this.$emit('copyRow', this.scenario, this.node);

View File

@ -61,6 +61,9 @@
}, },
active() { active() {
this.request.active = !this.request.active; this.request.active = !this.request.active;
if (this.node) {
this.node.expanded = this.request.active;
}
}, },
} }
} }

View File

@ -27,7 +27,7 @@
</template> </template>
<template v-slot:button> <template v-slot:button>
<el-button @click="runDebug" :tip="$t('api_test.run')" icon="el-icon-video-play" style="background-color: #409EFF;color: white;" size="mini" circle/> <el-button @click="runDebug" :tip="$t('api_test.run')" icon="el-icon-video-play" style="background-color: #409EFF;color: white;padding: 5px" size="mini" circle/>
</template> </template>
<div v-if="controller.loopType==='LOOP_COUNT'" draggable> <div v-if="controller.loopType==='LOOP_COUNT'" draggable>
<el-row> <el-row>
@ -246,6 +246,9 @@
}, },
active(item) { active(item) {
item.active = !item.active; item.active = !item.active;
if (this.node) {
this.node.expanded = item.active;
}
this.reload(); this.reload();
}, },
changeRadio() { changeRadio() {

View File

@ -5,7 +5,7 @@
<el-icon class="el-icon-more"></el-icon> <el-icon class="el-icon-more"></el-icon>
</el-link> </el-link>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="copy">复制步骤</el-dropdown-item> <!--<el-dropdown-item command="copy">复制步骤</el-dropdown-item>-->
<el-dropdown-item command="remove" v-tester>删除步骤</el-dropdown-item> <el-dropdown-item command="remove" v-tester>删除步骤</el-dropdown-item>
<el-dropdown-item command="scenarioVar" v-tester v-if="data.type==='scenario'">查看场景变量</el-dropdown-item> <el-dropdown-item command="scenarioVar" v-tester v-if="data.type==='scenario'">查看场景变量</el-dropdown-item>
<el-dropdown-item command="openScenario" v-tester v-if="data.type==='scenario' && data.referenced==='REF'">打开场景</el-dropdown-item> <el-dropdown-item command="openScenario" v-tester v-if="data.type==='scenario' && data.referenced==='REF'">打开场景</el-dropdown-item>

View File

@ -68,8 +68,8 @@
let projectId = ""; let projectId = "";
// envMap // envMap
if (!this.envMap) { if (!this.envMap || this.envMap.size === 0) {
projectId = getCurrentProjectID(); projectId = this.$store.state.projectId;
} else { } else {
// //
projectId = this.runData.projectId; projectId = this.runData.projectId;

View File

@ -178,6 +178,10 @@
<div v-else-if="apiInfo.requestBodyParamType == 'JSON-SCHEMA'" style="margin-left: 10px"> <div v-else-if="apiInfo.requestBodyParamType == 'JSON-SCHEMA'" style="margin-left: 10px">
<ms-json-code-edit :body="apiInfo.jsonSchemaBody" ref="jsonCodeEdit"/> <ms-json-code-edit :body="apiInfo.jsonSchemaBody" ref="jsonCodeEdit"/>
</div> </div>
<!-- <div v-else-if="apiInfo.requestBodyParamType == 'XML'" style="margin-left: 10px">-->
<!-- <ms-json-code-edit :body="apiInfo.jsonSchemaBody" ref="jsonCodeEdit"/>-->
<!-- <editor v-model="formatData" :lang="mode" @init="editorInit" :theme="theme" :height="height"/>-->
<!-- </div>-->
<div v-else class="showDataDiv"> <div v-else class="showDataDiv">
<br/> <br/>
<p style="margin: 0px 20px;" <p style="margin: 0px 20px;"
@ -423,7 +427,12 @@ export default {
formatRowData(dataType, data) { formatRowData(dataType, data) {
var returnData = data; var returnData = data;
if (data) { if (data) {
returnData = data.replace(/\n/g, '<br>');
if(dataType === 'XML'){
returnData = "<xmp>"+returnData+"</xmp>";
}else{
returnData = data.replace(/\n/g, '<br>');
}
} }
return returnData; return returnData;
}, },