版本升级1.0.3,swagger文档优化
This commit is contained in:
@@ -300,7 +300,7 @@ public class MgDocumentController {
|
||||
@PostMapping(value = "/addSwaggerResources")
|
||||
public ResponseJson<Object> addSwaggerResources(HttpServletRequest request, String swaggerJson, String resourcesUrl, String rewriteDomainUrl, String oldUrl, Integer openVisit) {
|
||||
// 通过json文档内容来添加
|
||||
ResponseJson<Object> responseJson = this.addSwaggerJsonApiDocs(request, swaggerJson, resourcesUrl);
|
||||
ResponseJson<Object> responseJson = this.addSwaggerJsonApiDocs(request, swaggerJson, resourcesUrl, rewriteDomainUrl, openVisit);
|
||||
if (responseJson != null) {
|
||||
return responseJson;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ public class MgDocumentController {
|
||||
* @param swaggerJson swagger的文档内容
|
||||
* @return 添加结果
|
||||
*/
|
||||
public ResponseJson<Object> addSwaggerJsonApiDocs(HttpServletRequest request, String swaggerJson, String resourcesUrl) {
|
||||
public ResponseJson<Object> addSwaggerJsonApiDocs(HttpServletRequest request, String swaggerJson, String resourcesUrl, String rewriteDomainUrl, Integer openVisit) {
|
||||
if (StringUtils.isNotBlank(swaggerJson)) {
|
||||
Integer nextId = 0;
|
||||
String customUrl = resourcesUrl;
|
||||
@@ -375,7 +375,7 @@ public class MgDocumentController {
|
||||
customUrl = customUrl.substring(0, customUrl.lastIndexOf("/"));
|
||||
customUrl = customUrl + Consts.PROXY_API_DOCS + "?id=" + nextId;
|
||||
}
|
||||
boolean addResult = this.addSwaggerLocationList(swaggerJson, null, customUrl, customUrl, 0);
|
||||
boolean addResult = this.addSwaggerLocationList(swaggerJson, rewriteDomainUrl, customUrl, customUrl, openVisit);
|
||||
if (addResult) {
|
||||
storageService.put(StorageKeys.PROXY_API_DOCS + nextId, swaggerJson);
|
||||
return DocResponseJson.ok();
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.zyplayer.doc.swagger.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.swagger.controller.vo.LocationListVo;
|
||||
import com.zyplayer.doc.swagger.controller.vo.SwaggerResourcesInfoVo;
|
||||
import com.zyplayer.doc.swagger.framework.constant.Consts;
|
||||
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
||||
import com.zyplayer.doc.swagger.framework.service.MgStorageService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -17,9 +19,7 @@ import springfox.documentation.swagger.web.SecurityConfiguration;
|
||||
import springfox.documentation.swagger.web.SwaggerResource;
|
||||
import springfox.documentation.swagger.web.UiConfiguration;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 承接了所有的ApiResourceController的接口
|
||||
@@ -41,7 +41,7 @@ public class ZyplayerSwaggerController {
|
||||
if (resourcesInfoVoList == null || resourcesInfoVoList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<SwaggerResource> resourceList = new LinkedList<>();
|
||||
Set<SwaggerResource> resourceList = new HashSet<>();
|
||||
resourcesInfoVoList.forEach(resource -> {
|
||||
resource.getResourceList().forEach(val -> {
|
||||
String location = val.getLocation();
|
||||
@@ -49,7 +49,21 @@ public class ZyplayerSwaggerController {
|
||||
});
|
||||
resourceList.addAll(resource.getResourceList());
|
||||
});
|
||||
return resourceList;
|
||||
List<LocationListVo> locationList = new LinkedList<>();
|
||||
String swaggerLocationListStr = storageService.get(StorageKeys.SWAGGER_LOCATION_LIST);
|
||||
if (StringUtils.isNotBlank(swaggerLocationListStr)) {
|
||||
locationList = JSON.parseArray(swaggerLocationListStr, LocationListVo.class);
|
||||
}
|
||||
for (LocationListVo listVo : locationList) {
|
||||
if (listVo.getLocation().contains(Consts.PROXY_API_DOCS)) {
|
||||
SwaggerResource resource = new SwaggerResource();
|
||||
resource.setLocation(listVo.getLocation());
|
||||
resource.setName(listVo.getName());
|
||||
resource.setSwaggerVersion("2.0");
|
||||
resourceList.add(resource);
|
||||
}
|
||||
}
|
||||
return new LinkedList<>(resourceList);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
|
||||
@@ -58,9 +58,9 @@
|
||||
支持多项目同时展示,多种文档目录的展示方案,多种自定义配置,满足各种使用习惯。
|
||||
本项目是完全从头写的,所以有任何属性未解析到、UI上有何建议都能及时处理得到。
|
||||
使用中您有任何的意见和建议都可到源码地址处反馈哦!<br/>
|
||||
源码地址:<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc-swagger</a>(还有其他很多功能哦),
|
||||
前端框架:<a target="_blank" href="http://zui.sexy">zui</a>(很不错),
|
||||
我的网站:<a target="_blank" href="http://kongjianzhou.com">空间轴</a>、<a target="_blank" href="http://zyplayer.com">自由发挥</a>(都已很久未维护)
|
||||
源码地址:<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc-swagger</a>,
|
||||
前端框架:<a target="_blank" href="http://zui.sexy">zui</a>,
|
||||
我的网站:<a target="_blank" href="http://kongjianzhou.com">空间轴</a>、<a target="_blank" href="http://zyplayer.com">自由发挥</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -127,8 +127,18 @@
|
||||
app.oldLocation = item.location;
|
||||
app.addNewDocumentInput = item.location;
|
||||
app.rewriteDomainUrl = item.rewriteDomainUrl;
|
||||
app.addNewSwaggerJson = "";
|
||||
app.openVisit = (item.openVisit == 1);
|
||||
$('#addNewDocumentModal').modal({moveable: true});
|
||||
if (item.location.indexOf('proxy-api-docs') > 0) {
|
||||
var docId = item.location.substring(item.location.indexOf("?id=") + 4);
|
||||
// 获取文档内容
|
||||
ajaxTemp(urlBase + "swagger-mg-ui/document/proxy-api-docs", "get", "text", {id: docId}, function (json) {
|
||||
app.addNewSwaggerJson = json;
|
||||
$('#addNewDocumentModal').modal({moveable: true});
|
||||
});
|
||||
} else {
|
||||
$('#addNewDocumentModal').modal({moveable: true});
|
||||
}
|
||||
},
|
||||
addNewDocument: function(){
|
||||
app.openVisit = false;
|
||||
|
||||
Reference in New Issue
Block a user