diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java index 3472c1b7be..06d2dbcc8a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java @@ -936,9 +936,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { if (body != null) { // 将请求体转换成相应的格式导出 String bodyType = body.getString("type"); - if (bodyType == null) { - - } else if (bodyType.equalsIgnoreCase("JSON")) { + if (StringUtils.isNotBlank(bodyType) && bodyType.equalsIgnoreCase("JSON")) { try { if (StringUtils.equals(body.getString("format"), "JSON-SCHEMA")) { String jsonSchema = body.getString("jsonSchema"); @@ -986,14 +984,17 @@ public class Swagger3Parser extends SwaggerAbstractParser { } } - String type = respOrReq.getJSONObject("body").getString("type"); + String type = null; + if (respOrReq.getJSONObject("body") != null) { + type = respOrReq.getJSONObject("body").getString("type"); + } JSONObject content = new JSONObject(); Object schema = bodyInfo; // 请求体部分 JSONObject typeName = new JSONObject(); if (schema != null) { typeName.put("schema", schema);//schema.getJSONObject("properties").size() == 0? "" : } - if (type != null && StringUtils.isNotBlank(type)) { + if (StringUtils.isNotBlank(type)) { content.put(typeMap.get(type), typeName); } return content; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index bbd7861248..4a9e39e712 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1335,7 +1335,7 @@ public class ApiAutomationService { _importCreate(sameList, batchMapper, extApiScenarioMapper, scenarioWithBLOBs, apiTestImportRequest, apiTestCaseMapper, apiDefinitionMapper); } else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) { if (CollectionUtils.isEmpty(sameList)) { - if (scenarioWithBLOBs.getVersionId() == null || scenarioWithBLOBs.getVersionId().equals("new")) { + if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("new")) { scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); } else { scenarioWithBLOBs.setOrder(getImportNextOrder(request.getProjectId())); 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 8a0f984d92..1ee641e7a2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -805,7 +805,7 @@ public class ApiDefinitionService { if (CollectionUtils.isEmpty(collect)) { String originId = apiDefinition.getId(); //postman 可能含有前置脚本,接口定义去掉脚本 - if (apiDefinition.getVersionId() == null || apiDefinition.getVersionId().equals("new")) { + if (apiDefinition.getVersionId() != null && apiDefinition.getVersionId().equals("new")) { apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); } else { apiDefinition.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));