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 b779dfe360
commit eb00835b8b
1 changed files with 12 additions and 9 deletions

View File

@ -252,14 +252,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;
}
@ -272,14 +273,13 @@ public class Swagger3Parser extends SwaggerAbstractParser {
}
}
private void parseResponseCode(String response, HttpResponse msResponse) {
if (StringUtils.isNotEmpty(response)) {
try {
msResponse.setStatusCode(JSON.parseObject(response, List.class));
} catch (Exception e) {
LogUtil.error(e);
}
private void parseResponseCode(List<KeyValue> statusCode, String responseCode, ApiResponse response) {
try {
statusCode.add(new KeyValue(responseCode, response.getDescription(), response.getDescription()));
} catch (Exception e) {
LogUtil.error(e);
}
}
private void parseResponseBody(ApiResponse response, Body body) {
@ -317,6 +317,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<>();