dubbo文档操作接口和页面

This commit is contained in:
暮光:城中城
2019-02-15 20:58:37 +08:00
parent 4a7541d7e7
commit 4d51b48429
42 changed files with 76 additions and 3913 deletions

View File

@@ -2,7 +2,6 @@ package com.zyplayer.doc.swagger.controller;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zyplayer.doc.core.json.DocResponseJson;
import com.zyplayer.doc.core.json.ResponseJson;
import com.zyplayer.doc.swagger.controller.vo.LocationListVo;
@@ -136,12 +135,6 @@ public class MgDocumentController {
for (LocationListVo location : locationList) {
try {
String resourceStr = HttpRequest.get(location.getLocation()).timeout(3000).execute().body();
Map<String, Object> jsonObject = JSON.parseObject(resourceStr, new TypeReference<HashMap<String, Object>>(){});
if (jsonObject == null || jsonObject.isEmpty()) {
continue;
}
jsonObject.put("fullUrl", location);
String resourcesUrl = location.getLocation();
int indexV2 = location.getLocation().indexOf("/v2");
if (indexV2 >= 0) {
@@ -404,7 +397,17 @@ public class MgDocumentController {
*/
private boolean addSwaggerLocationList(String resourcesStr, String rewriteDomainUrl, String locationUrl, String oldUrl, Integer openVisit) {
try {
SwaggerLocationVo swaggerLocationVo = JSON.parseObject(resourcesStr, SwaggerLocationVo.class);
SwaggerLocationVo swaggerLocationVo = null;
try {
swaggerLocationVo = JSON.parseObject(resourcesStr, SwaggerLocationVo.class);
} catch (Exception e) {
logger.error("获取文档失败,尝试字符串匹配:{}", e.getMessage());
// 由于存在$ref这样的字符串JSON解析可能会失败尝试字符串匹配
if (resourcesStr.startsWith("{\"swagger\":\"")) {
swaggerLocationVo = new SwaggerLocationVo();
swaggerLocationVo.setSwagger("maybe");
}
}
if (swaggerLocationVo != null && StringUtils.isNotBlank(swaggerLocationVo.getSwagger())) {
List<LocationListVo> locationList = this.getLocationSet();
// 组装新的对象

View File

@@ -2,7 +2,6 @@ package com.zyplayer.doc.swagger.controller;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zyplayer.doc.core.json.DocResponseJson;
import com.zyplayer.doc.swagger.controller.vo.LocationListVo;
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
@@ -18,7 +17,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -71,11 +73,6 @@ public class MgOpenDocController {
for (LocationListVo location : locationList) {
try {
String resourceStr = HttpRequest.get(location.getLocation()).timeout(3000).execute().body();
Map<String, Object> jsonObject = JSON.parseObject(resourceStr, new TypeReference<HashMap<String, Object>>(){});
if (jsonObject == null || jsonObject.isEmpty()) {
continue;
}
jsonObject.put("fullUrl", location);
String resourcesUrl = location.getLocation();
int indexV2 = location.getLocation().indexOf("/v2");
if (indexV2 >= 0) {