fix: swagger导入部分请求响应体没有描述

【【泰远淑】通过swagger同步的API,响应体部分的描述未能正确同步过来,请修复】https://www.tapd.cn/33805590/bugtrace/bugs/view?bug_id=1133805590001008723
This commit is contained in:
chenjianxing 2021-12-19 18:12:03 +08:00 committed by BugKing
parent 1afcd68c40
commit f2f4d5fa07
1 changed files with 12 additions and 9 deletions

View File

@ -207,14 +207,15 @@ public class Swagger3Parser extends SwaggerAbstractParser {
responses.forEach((responseCode, response) -> {
parseResponseHeader(response, msResponse.getHeaders());
parseResponseBody(response, msResponse.getBody());
parseResponseCode(responseCode, msResponse);
});
} else {
parseResponseHeader(apiResponse, msResponse.getHeaders());
parseResponseBody(apiResponse, msResponse.getBody());
parseResponseCode("200", msResponse);
}
}
responses.forEach((responseCode, response) -> {
parseResponseCode(msResponse.getStatusCode(), responseCode, response);
});
return msResponse;
}
@ -227,14 +228,13 @@ public class Swagger3Parser extends SwaggerAbstractParser {
}
}
private void parseResponseCode(String response, HttpResponse msResponse) {
if (StringUtils.isNotEmpty(response)) {
private void parseResponseCode(List<KeyValue> statusCode, String responseCode, ApiResponse response) {
try {
msResponse.setStatusCode(JSON.parseObject(response, List.class));
statusCode.add(new KeyValue(responseCode, response.getDescription(), response.getDescription()));
} catch (Exception e) {
LogUtil.error(e);
}
}
}
private void parseResponseBody(ApiResponse response, Body body) {
@ -272,6 +272,9 @@ public class Swagger3Parser extends SwaggerAbstractParser {
return;
}
mediaType = content.get(contentType);
if (contentType.equals("*/*")) {
contentType = org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
}
}
Set<String> refSet = new HashSet<>();