fix(接口测试): 修复导入特殊的swagger文件,不显示rest参数的缺陷
https://github.com/metersphere/metersphere/issues/27986
This commit is contained in:
parent
2127170ca6
commit
9d6e84cf4d
|
@ -146,6 +146,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
||||||
ApiDefinitionWithBLOBs apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method.name(), importRequest);
|
ApiDefinitionWithBLOBs apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method.name(), importRequest);
|
||||||
apiDefinition.setDescription(operation.getDescription());
|
apiDefinition.setDescription(operation.getDescription());
|
||||||
parseParameters(operation, request);
|
parseParameters(operation, request);
|
||||||
|
parseParameters(path,request);
|
||||||
addBodyHeader(request);
|
addBodyHeader(request);
|
||||||
if (StringUtils.isNotBlank(basePath)) {
|
if (StringUtils.isNotBlank(basePath)) {
|
||||||
String pathStr = (basePath + apiDefinition.getPath()).replaceAll("//", "/");
|
String pathStr = (basePath + apiDefinition.getPath()).replaceAll("//", "/");
|
||||||
|
@ -250,6 +251,25 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void parseParameters(Path path, MsHTTPSamplerProxy request) {
|
||||||
|
if (path.getParameters() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Parameter> parameters = path.getParameters();
|
||||||
|
// 处理特殊格式 rest参数是和请求平级的情况
|
||||||
|
|
||||||
|
for (Parameter parameter : parameters) {
|
||||||
|
if (StringUtils.isNotBlank(parameter.getIn())) {
|
||||||
|
switch (parameter.getIn()) {
|
||||||
|
case SwaggerParameterType.PATH -> parsePathParameters(parameter, request.getRest());
|
||||||
|
case SwaggerParameterType.QUERY -> parseQueryParameters(parameter, request.getArguments());
|
||||||
|
case SwaggerParameterType.HEADER -> parseHeaderParameters(parameter, request.getHeaders());
|
||||||
|
case SwaggerParameterType.COOKIE -> parseCookieParameters(parameter, request.getHeaders());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getBodyType(Operation operation) {
|
private String getBodyType(Operation operation) {
|
||||||
if (CollectionUtils.isEmpty(operation.getConsumes())) {
|
if (CollectionUtils.isEmpty(operation.getConsumes())) {
|
||||||
return Body.JSON_STR;
|
return Body.JSON_STR;
|
||||||
|
|
Loading…
Reference in New Issue