注释完善
This commit is contained in:
@@ -82,6 +82,7 @@ public class SwaggerDocumentController {
|
||||
String resourcesStr = swaggerHttpRequestService.requestSwaggerUrl(request, docUrl, swaggerDomain);
|
||||
resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocResponseJson.warn("解析文档地址失败:" + e.getMessage());
|
||||
}
|
||||
if (resourceList == null || resourceList.isEmpty()) {
|
||||
@@ -98,10 +99,8 @@ public class SwaggerDocumentController {
|
||||
swaggerDoc.setName(resource.getName());
|
||||
swaggerDocService.save(swaggerDoc);
|
||||
}
|
||||
} else if (SwaggerDocUtil.isSwaggerLocation(docUrl)) {
|
||||
swaggerDocService.saveOrUpdate(swaggerDoc);
|
||||
} else {
|
||||
return DocResponseJson.warn("不支持的地址:" + docUrl);
|
||||
swaggerDocService.saveOrUpdate(swaggerDoc);
|
||||
}
|
||||
} else {
|
||||
swaggerDocService.saveOrUpdate(swaggerDoc);
|
||||
|
||||
@@ -70,6 +70,7 @@ public class SwaggerProxyController {
|
||||
String contentStr = swaggerHttpRequestService.requestSwaggerUrl(request, swaggerDoc.getDocUrl(), docsDomain);
|
||||
return new ResponseEntity<>(new Json(contentStr), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(DocResponseJson.warn("请求文档失败"), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.swaggerplus.controller.param;
|
||||
|
||||
/**
|
||||
* 参数信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-11-04
|
||||
*/
|
||||
public class ParamData {
|
||||
private String code;
|
||||
private String value;
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.zyplayer.doc.swaggerplus.controller.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代理请求结果
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-11-04
|
||||
*/
|
||||
public class ProxyRequestResultVo {
|
||||
private List<HttpCookieVo> cookies;
|
||||
private List<HttpHeaderVo> headers;
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.zyplayer.doc.swaggerplus.controller.vo;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
|
||||
/**
|
||||
* swagger资源信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-11-04
|
||||
*/
|
||||
public class SwaggerResourceVo implements Comparable<SwaggerResourceVo> {
|
||||
private String name;
|
||||
private String url;
|
||||
|
||||
@@ -5,6 +5,12 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 开启swagger模块注解
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-11-04
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zyplayer.doc.swaggerplus.framework.utils;
|
||||
|
||||
/**
|
||||
* swagger文档工具类
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-11-04
|
||||
*/
|
||||
public class SwaggerDocUtil {
|
||||
|
||||
public static String replaceSwaggerResources(String docUrl) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.zyplayer.doc.swaggerplus.service;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.http.*;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.http.Method;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.SwaggerGlobalParam;
|
||||
import com.zyplayer.doc.data.service.manage.SwaggerGlobalParamService;
|
||||
@@ -22,11 +23,16 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* swagger请求服务
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-11-04
|
||||
*/
|
||||
@Service
|
||||
public class SwaggerHttpRequestService {
|
||||
|
||||
@@ -127,7 +133,7 @@ public class SwaggerHttpRequestService {
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
private HttpResponse getHttpResponse(HttpServletRequest request, ProxyRequestParam requestParam){
|
||||
private HttpResponse getHttpResponse(HttpServletRequest request, ProxyRequestParam requestParam) {
|
||||
// 执行请求
|
||||
Method method = requestMethodMap.get(requestParam.getMethod());
|
||||
if (method == null) {
|
||||
|
||||
Reference in New Issue
Block a user