refactor(接口测试): 优化swagger文件默认响应码的展示
This commit is contained in:
parent
46afc6c124
commit
4263347d7e
|
@ -15,7 +15,7 @@ public class TempFileUtils {
|
|||
}
|
||||
|
||||
public static boolean isImage(String type) {
|
||||
return StringUtils.equalsAnyIgnoreCase(type, "jpg", "jpeg", "png", "gif", "bmp", "svg", "ico", "webp", "apng", "avif");
|
||||
return StringUtils.equalsAnyIgnoreCase(type, "jpg", "jpeg", "png", "gif", "bmp", "svg", "ico", "webp", "apng", "avif","pdf");
|
||||
}
|
||||
|
||||
public static String getFileNameByPath(String filePath) {
|
||||
|
|
|
@ -186,7 +186,7 @@ public class Swagger3Parser<T> extends ApiImportAbstractParser<ApiDefinitionImpo
|
|||
responseBody.forEach((key, value) -> {
|
||||
HttpResponse httpResponse = new HttpResponse();
|
||||
//TODO headers
|
||||
httpResponse.setStatusCode(key);
|
||||
httpResponse.setStatusCode(StringUtils.equals("default", key) ? "200" :key);
|
||||
ResponseBody body = new ResponseBody();
|
||||
Map<String, io.swagger.v3.oas.models.headers.Header> headers = value.getHeaders();
|
||||
if (MapUtils.isNotEmpty(headers)) {
|
||||
|
|
|
@ -183,11 +183,14 @@ public class MockServerService {
|
|||
String fileId = responseBody.getBinaryBody().getFile().getFileId();
|
||||
String fileName = responseBody.getBinaryBody().getFile().getFileName();
|
||||
String fileType = StringUtils.substring(fileName, fileName.lastIndexOf(".") + 1);
|
||||
MediaType mediaType = MediaType.parseMediaType("application/octet-stream");
|
||||
MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
if (responseBody.getBinaryBody().isSendAsBody()) {
|
||||
String contentType = "text/plain";
|
||||
String contentType = MediaType.TEXT_PLAIN_VALUE;
|
||||
if (TempFileUtils.isImage(fileType)) {
|
||||
contentType = "image/" + fileType;
|
||||
if (StringUtils.equalsIgnoreCase(fileType, "pdf")) {
|
||||
contentType = MediaType.APPLICATION_PDF_VALUE;
|
||||
}
|
||||
}
|
||||
mediaType = MediaType.parseMediaType(contentType);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue