fix: 导入id和请求id一致

This commit is contained in:
chenjianxing 2020-12-03 19:36:08 +08:00
parent 18d2d68486
commit 5d37c09413
5 changed files with 5 additions and 14 deletions

View File

@ -11,7 +11,6 @@ import io.metersphere.api.dto.parse.ApiImport;
import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.Body;
import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.commons.constants.MsRequestBodyType;
import io.metersphere.commons.constants.SwaggerParameterType; import io.metersphere.commons.constants.SwaggerParameterType;
import io.swagger.models.*; import io.swagger.models.*;
import io.swagger.models.parameters.*; import io.swagger.models.parameters.*;
@ -64,6 +63,7 @@ public class Swagger2Parser extends ApiImportAbstractParser {
MsHTTPSamplerProxy request = buildRequest(operation, pathName, method.name()); MsHTTPSamplerProxy request = buildRequest(operation, pathName, method.name());
parseParameters(operation, request); parseParameters(operation, request);
apiDefinition.setRequest(JSON.toJSONString(request)); apiDefinition.setRequest(JSON.toJSONString(request));
apiDefinition.setId(request.getId());
results.add(apiDefinition); results.add(apiDefinition);

View File

@ -227,7 +227,6 @@ public class ApiDefinitionService {
private ApiDefinition createTest(ApiDefinitionResult request, ApiDefinitionMapper batchMapper) { private ApiDefinition createTest(ApiDefinitionResult request, ApiDefinitionMapper batchMapper) {
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest(); SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
BeanUtils.copyBean(saveReq, request); BeanUtils.copyBean(saveReq, request);
saveReq.setId(UUID.randomUUID().toString());
checkNameExist(saveReq); checkNameExist(saveReq);
final ApiDefinitionWithBLOBs test = new ApiDefinitionWithBLOBs(); final ApiDefinitionWithBLOBs test = new ApiDefinitionWithBLOBs();
BeanUtils.copyBean(test, request); BeanUtils.copyBean(test, request);
@ -340,7 +339,6 @@ public class ApiDefinitionService {
item.setModuleId(importRequest.getModuleId()); item.setModuleId(importRequest.getModuleId());
item.setModulePath(importRequest.getModulePath()); item.setModulePath(importRequest.getModulePath());
item.setEnvironmentId(importRequest.getEnvironmentId()); item.setEnvironmentId(importRequest.getEnvironmentId());
item.setId(UUID.randomUUID().toString());
item.setUserId(null); item.setUserId(null);
createTest(item, batchMapper); createTest(item, batchMapper);
if (i % 300 == 0) { if (i % 300 == 0) {

View File

@ -103,24 +103,20 @@
modeChange(mode) { modeChange(mode) {
switch (this.body.type) { switch (this.body.type) {
case "JSON": case "JSON":
this.body.format = "json";
this.setContentType("application/json"); this.setContentType("application/json");
break; break;
case "XML": case "XML":
this.body.format = "xml";
this.setContentType("text/xml"); this.setContentType("text/xml");
break; break;
case "WWW_FORM": case "WWW_FORM":
this.body.format = "form";
this.setContentType("application/x-www-form-urlencoded"); this.setContentType("application/x-www-form-urlencoded");
break; break;
// todo from data
case "BINARY": case "BINARY":
this.body.format = "binary";
this.setContentType("application/octet-stream"); this.setContentType("application/octet-stream");
break; break;
default: default:
this.removeContentType(); this.removeContentType();
this.body.format = mode;
break; break;
} }
}, },
@ -154,10 +150,7 @@
created() { created() {
if (!this.body.type) { if (!this.body.type) {
this.body.type = BODY_TYPE.KV; this.body.type = BODY_TYPE.FORM_DATA;
}
if (!this.body.format) {
this.body.format = BODY_FORMAT.TEXT;
} }
this.body.kvs.forEach(param => { this.body.kvs.forEach(param => {
if (!param.type) { if (!param.type) {

View File

@ -736,7 +736,7 @@ export class Body extends BaseConfig {
} }
isKV() { isKV() {
return this.type === BODY_TYPE.KV; return [BODY_TYPE.FORM_DATA, BODY_TYPE.WWW_FORM, BODY_TYPE.BINARY].indexOf(this.type) > 0;
} }
} }

View File

@ -42,7 +42,7 @@
return { return {
editor: null, editor: null,
error: false, error: false,
json: JSON.parse(this.value), json: JSON.parse(this.value ? this.value : "{}"),
internalChange: false, internalChange: false,
expandedModes: ["tree", "view", "form"], expandedModes: ["tree", "view", "form"],
}; };