fix: swagger导入部分请求响应体没有描述
【【泰远淑】通过swagger同步的API,响应体部分的描述未能正确同步过来,请修复】https://www.tapd.cn/33805590/bugtrace/bugs/view?bug_id=1133805590001008723
This commit is contained in:
parent
1afcd68c40
commit
f2f4d5fa07
|
@ -207,14 +207,15 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
responses.forEach((responseCode, response) -> {
|
responses.forEach((responseCode, response) -> {
|
||||||
parseResponseHeader(response, msResponse.getHeaders());
|
parseResponseHeader(response, msResponse.getHeaders());
|
||||||
parseResponseBody(response, msResponse.getBody());
|
parseResponseBody(response, msResponse.getBody());
|
||||||
parseResponseCode(responseCode, msResponse);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
parseResponseHeader(apiResponse, msResponse.getHeaders());
|
parseResponseHeader(apiResponse, msResponse.getHeaders());
|
||||||
parseResponseBody(apiResponse, msResponse.getBody());
|
parseResponseBody(apiResponse, msResponse.getBody());
|
||||||
parseResponseCode("200", msResponse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
responses.forEach((responseCode, response) -> {
|
||||||
|
parseResponseCode(msResponse.getStatusCode(), responseCode, response);
|
||||||
|
});
|
||||||
return msResponse;
|
return msResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,14 +228,13 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseResponseCode(String response, HttpResponse msResponse) {
|
private void parseResponseCode(List<KeyValue> statusCode, String responseCode, ApiResponse response) {
|
||||||
if (StringUtils.isNotEmpty(response)) {
|
try {
|
||||||
try {
|
statusCode.add(new KeyValue(responseCode, response.getDescription(), response.getDescription()));
|
||||||
msResponse.setStatusCode(JSON.parseObject(response, List.class));
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
LogUtil.error(e);
|
||||||
LogUtil.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseResponseBody(ApiResponse response, Body body) {
|
private void parseResponseBody(ApiResponse response, Body body) {
|
||||||
|
@ -272,6 +272,9 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mediaType = content.get(contentType);
|
mediaType = content.get(contentType);
|
||||||
|
if (contentType.equals("*/*")) {
|
||||||
|
contentType = org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> refSet = new HashSet<>();
|
Set<String> refSet = new HashSet<>();
|
||||||
|
|
Loading…
Reference in New Issue