diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java index 687ab38786..b00edd44ca 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java @@ -11,7 +11,6 @@ import io.metersphere.api.dto.parse.ApiImport; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.request.RequestType; -import io.metersphere.commons.constants.MsRequestBodyType; import io.metersphere.commons.constants.SwaggerParameterType; import io.swagger.models.*; import io.swagger.models.parameters.*; @@ -64,6 +63,7 @@ public class Swagger2Parser extends ApiImportAbstractParser { MsHTTPSamplerProxy request = buildRequest(operation, pathName, method.name()); parseParameters(operation, request); apiDefinition.setRequest(JSON.toJSONString(request)); + apiDefinition.setId(request.getId()); results.add(apiDefinition); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 05f3665256..8786acb243 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -227,7 +227,6 @@ public class ApiDefinitionService { private ApiDefinition createTest(ApiDefinitionResult request, ApiDefinitionMapper batchMapper) { SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest(); BeanUtils.copyBean(saveReq, request); - saveReq.setId(UUID.randomUUID().toString()); checkNameExist(saveReq); final ApiDefinitionWithBLOBs test = new ApiDefinitionWithBLOBs(); BeanUtils.copyBean(test, request); @@ -340,7 +339,6 @@ public class ApiDefinitionService { item.setModuleId(importRequest.getModuleId()); item.setModulePath(importRequest.getModulePath()); item.setEnvironmentId(importRequest.getEnvironmentId()); - item.setId(UUID.randomUUID().toString()); item.setUserId(null); createTest(item, batchMapper); if (i % 300 == 0) { diff --git a/frontend/src/business/components/api/definition/components/body/ApiBody.vue b/frontend/src/business/components/api/definition/components/body/ApiBody.vue index aaa10515b9..adaa1d4d8c 100644 --- a/frontend/src/business/components/api/definition/components/body/ApiBody.vue +++ b/frontend/src/business/components/api/definition/components/body/ApiBody.vue @@ -103,24 +103,20 @@ modeChange(mode) { switch (this.body.type) { case "JSON": - this.body.format = "json"; this.setContentType("application/json"); break; case "XML": - this.body.format = "xml"; this.setContentType("text/xml"); break; case "WWW_FORM": - this.body.format = "form"; this.setContentType("application/x-www-form-urlencoded"); break; + // todo from data case "BINARY": - this.body.format = "binary"; this.setContentType("application/octet-stream"); break; default: this.removeContentType(); - this.body.format = mode; break; } }, @@ -154,10 +150,7 @@ created() { if (!this.body.type) { - this.body.type = BODY_TYPE.KV; - } - if (!this.body.format) { - this.body.format = BODY_FORMAT.TEXT; + this.body.type = BODY_TYPE.FORM_DATA; } this.body.kvs.forEach(param => { if (!param.type) { diff --git a/frontend/src/business/components/api/definition/model/ApiTestModel.js b/frontend/src/business/components/api/definition/model/ApiTestModel.js index e1c13d65f3..adce92b3e1 100644 --- a/frontend/src/business/components/api/definition/model/ApiTestModel.js +++ b/frontend/src/business/components/api/definition/model/ApiTestModel.js @@ -736,7 +736,7 @@ export class Body extends BaseConfig { } isKV() { - return this.type === BODY_TYPE.KV; + return [BODY_TYPE.FORM_DATA, BODY_TYPE.WWW_FORM, BODY_TYPE.BINARY].indexOf(this.type) > 0; } } diff --git a/frontend/src/business/components/common/components/MsJsonCodeEdit.vue b/frontend/src/business/components/common/components/MsJsonCodeEdit.vue index c830d6bd3a..e908453689 100644 --- a/frontend/src/business/components/common/components/MsJsonCodeEdit.vue +++ b/frontend/src/business/components/common/components/MsJsonCodeEdit.vue @@ -42,7 +42,7 @@ return { editor: null, error: false, - json: JSON.parse(this.value), + json: JSON.parse(this.value ? this.value : "{}"), internalChange: false, expandedModes: ["tree", "view", "form"], };