版本升级1.0.3,swagger文档优化

This commit is contained in:
暮光:城中城
2019-08-17 21:16:32 +08:00
parent 2c11dbdcf0
commit 4d6b09d640
17 changed files with 409 additions and 41 deletions

View File

@@ -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();

View File

@@ -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