fix(接口测试): 修复swagger文件导入问题
--bug=1019960--user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001019960
This commit is contained in:
parent
881e92aaad
commit
49df25ba27
|
@ -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\": []");
|
||||
}
|
||||
|
||||
// 鉴权设置
|
||||
|
|
Loading…
Reference in New Issue