fix(接口测试): 解决接口导出为swagger时不带模块问题

--user=郭雨琦
--bug=1014699
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014699
This commit is contained in:
guoyuqi 2022-07-08 15:55:46 +08:00 committed by xiaomeinvG
parent 0dd91944aa
commit 82812a58db
3 changed files with 8 additions and 7 deletions

View File

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

View File

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

View File

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