diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java index c9c1a03392..ea7db5d677 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java @@ -51,7 +51,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { sourceStr = getApiTestStr(source); // 导入的二进制文件转换为 String //注:有一特殊情况,swagger2.0 文件里如果在response的parameter参数下的properties的参数里存在 required 为string类型, //swagger2.0不会导入,需替换一下 - sourceStr = replaceStr(sourceStr); + sourceStr = replaceStr(sourceStr); JSONObject jsonObject = JSONUtil.parseObject(sourceStr); if (jsonObject.opt("swagger") == null || jsonObject.opt("swagger") == "null" || jsonObject.opt("swagger") == StringUtils.SPACE) { @@ -73,7 +73,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { } public static String replaceStr(String sourceStr) { - return sourceStr.replaceAll("\"required\": \".*\"", "\"required\": []"); + return sourceStr.replaceAll("\"required\": \"(.*?)\"", "\"required\": []"); } // 鉴权设置