fix: swagger2导入本地文件走的swagger3的解析流程

--bug=1009407 --user=陈建星 [ github#8970]接口导入:swagger 2.0 json文件导入后,有些接口参数没有导入到MeterSphere系统里。 https://www.tapd.cn/55049933/s/10884811
This commit is contained in:
chenjianxing 2021-12-30 11:46:36 +08:00 committed by fit2-zhao
parent 94b3694dfb
commit 197ae58215
2 changed files with 2 additions and 2 deletions

View File

@ -37,7 +37,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
swagger = new SwaggerParser().read(request.getSwaggerUrl(), auths, true);
} else {
sourceStr = getApiTestStr(source); // 导入的二进制文件转换为 String
swagger = new SwaggerParser().readWithInfo(sourceStr, auths, true).getSwagger();
swagger = new SwaggerParser().readWithInfo(sourceStr).getSwagger();
}
if (swagger == null || swagger.getSwagger() == null) { // 不是 2.0 版本则尝试转换 3.0
Swagger3Parser swagger3Parser = new Swagger3Parser();

View File

@ -57,7 +57,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
if (StringUtils.isNotBlank(request.getSwaggerUrl())) {
result = new OpenAPIParser().readLocation(request.getSwaggerUrl(), auths, null);
} else {
result = new OpenAPIParser().readContents(sourceStr, auths, null);
result = new OpenAPIParser().readContents(sourceStr, null, null);
}
if (result == null) {
MSException.throwException("解析失败,请确认选择的是 swagger 格式!");