diff --git a/zyplayer-doc-manage/src/main/resources/application.yml b/zyplayer-doc-manage/src/main/resources/application.yml index 797d5108..b76023e9 100644 --- a/zyplayer-doc-manage/src/main/resources/application.yml +++ b/zyplayer-doc-manage/src/main/resources/application.yml @@ -41,7 +41,7 @@ zyplayer: swagger: proxy-request: # 允许代理请求的域名,正则表达式,多个使用 ; 分割,必须设置,防止通过代理接口访问到内部资源,实在觉得没必要可设置为:.+ - white-domain: \S+\.zyplayer\.com;127.0.1:8080;\S+\.xiaominfo\.com; + white-domain: .+ # ------dubbo相关配置------ dubbo: # 优先使用zookeeper,未配置时找nacos的配置 diff --git a/zyplayer-doc-swagger/src/main/resources/export/js/mg-ui-tag.js b/zyplayer-doc-swagger/src/main/resources/export/js/mg-ui-tag.js index 85bfebcf..d7e7b0e4 100644 --- a/zyplayer-doc-swagger/src/main/resources/export/js/mg-ui-tag.js +++ b/zyplayer-doc-swagger/src/main/resources/export/js/mg-ui-tag.js @@ -1,128 +1,128 @@ -/** - * 以每个Tag方式生成并展示: - * 核心信息控制器 - * /api/data/getDataList - * /api/data/getDataDetail - * 跟进控制器 - * /api/track/getTrackList - * /api/track/getTrackDetail - * - * 先把树形的写完了再写这个,, - * - * @author 暮光:城中城 - * @since 2018年5月26日 -*/ - -function createTreeViewByTag(json, keywords) { - var pathIndex = {}; - var paths = json.paths; - var domain = json.domainUrl;// 服务器代理会返回此属性 - if(isEmpty(domain)) { - domain = "http://" + json.host + json.basePath; - } - if(domain.endWith("/")) { - domain = domain.substring(0, domain.length - 1); - } - if (isEmptyObject(paths)) { - return; - } - //console.log(paths); - Object.keys(paths).forEach(function(key){ - //console.log(key, paths[key]); - if(!findInPathsValue(key, paths[key], keywords)) { - return; - } - setRequestMethodForTag(domain, paths[key], pathIndex, key, "get"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "head"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "post"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "put"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "patch"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "delete"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "options"); - setRequestMethodForTag(domain, paths[key], pathIndex, key, "trace"); - }); - //console.log(pathIndex); - var htmlStr = '
  • '; - htmlStr += ''+json.info.title+''; - htmlStr += ''; - htmlStr += '
  • '; - $('#apiPathTree .projects').append(htmlStr); - projectTreeIdIndex++; -} - -/** - * 设置对象的各种请求方式,存在则复制 - * @param source 资源,原始json的paths的指定对象 - * @param pathObj 当前的待赋值对象 - * @param url url绝对路径 - * @param method 请求方式,post、get... - * @returns - */ -function setRequestMethodForTag(domain, source, pathObj, url, method) { - if (isEmpty(source[method])) { - return; - } - source[method].tags.forEach(function(val, index) { - var tempObj = pathObj[val]; - if(isEmpty(tempObj)) { - tempObj = pathObj[val] = {}; - } - var tempUrlObj = tempObj[url]; - if(isEmpty(tempUrlObj)) { - tempUrlObj = tempObj[url] = {}; - } - var tempPath = projectTreeIdIndex + url + "." + method; - tempUrlObj[method] = source[method]; - tempUrlObj[method].path = tempPath; - tempUrlObj[method].url = url; - tempUrlObj[method].method = method; - tempUrlObj[method].domain = domain; - treePathDataMap.set(tempPath, source[method]); - }); -} - -/** - * 将对象列表递归的方式转换成文档格式html字符串 - * @param pathData 处理后的对象列表 - * @returns 生成的html字符串 - */ -function getTreeHtmlForTag(pathData, treeIdStr) { - var tempStr = ""; - var indexNow = 1; - // get, head, post, put, patch, delete, options, trace - var actionArrays = ["get", "head", "post", "put", "patch", "delete", "options", "trace"]; - Object.keys(pathData).forEach(function(key){ - var tempNode = pathData[key]; - var tempTreeId = treeIdStr + "_" + indexNow; - // 只有一个子元素,而且有method元素,说明是只有一个节点 - var nodeSub = getObjectFirstAttributeIfOnly(tempNode); - if(nodeSub != null && isNotEmpty(nodeSub.method)) { - var summary = isEmpty(nodeSub.summary) ? "" : "(" + nodeSub.summary + ")"; - if(summary.length > 10){ - summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字 - } - nodeSub.treeId = tempTreeId; - tempStr += '
  • '+key+''+summary+'
  • '; - } else if(haveString(actionArrays, key)) { - //console.log(tempTreeId); - tempNode.treeId = tempTreeId; - var summary = isEmpty(tempNode.summary) ? "" : "("+tempNode.summary+")"; - if(summary.length > 10){ - summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字 - } - tempStr += '
  • '+key+''+summary+'
  • '; - } else { - tempStr += '
  • '; - tempStr += ''+key+''; - tempStr += ''; - tempStr += '
  • '; - } - indexNow++; - }); - return tempStr; -} - +/** + * 以每个Tag方式生成并展示: + * 核心信息控制器 + * /api/data/getDataList + * /api/data/getDataDetail + * 跟进控制器 + * /api/track/getTrackList + * /api/track/getTrackDetail + * + * 先把树形的写完了再写这个,, + * + * @author 暮光:城中城 + * @since 2018年5月26日 +*/ + +function createTreeViewByTag(json, keywords) { + var pathIndex = {}; + var paths = json.paths; + var domain = json.domainUrl;// 服务器代理会返回此属性 + if(isEmpty(domain)) { + domain = "http://" + json.host + json.basePath; + } + if(domain.endWith("/")) { + domain = domain.substring(0, domain.length - 1); + } + if (isEmptyObject(paths)) { + return; + } + //console.log(paths); + Object.keys(paths).forEach(function(key){ + //console.log(key, paths[key]); + if(!findInPathsValue(key, paths[key], keywords)) { + return; + } + setRequestMethodForTag(domain, paths[key], pathIndex, key, "get"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "head"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "post"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "put"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "patch"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "delete"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "options"); + setRequestMethodForTag(domain, paths[key], pathIndex, key, "trace"); + }); + //console.log(pathIndex); + var htmlStr = '
  • '; + htmlStr += ''+json.info.title+''; + htmlStr += ''; + htmlStr += '
  • '; + $('#apiPathTree .projects').append(htmlStr); + projectTreeIdIndex++; +} + +/** + * 设置对象的各种请求方式,存在则复制 + * @param source 资源,原始json的paths的指定对象 + * @param pathObj 当前的待赋值对象 + * @param url url绝对路径 + * @param method 请求方式,post、get... + * @returns + */ +function setRequestMethodForTag(domain, source, pathObj, url, method) { + if (isEmpty(source[method]) || !source[method].tags) { + return; + } + source[method].tags.forEach(function(val, index) { + var tempObj = pathObj[val]; + if(isEmpty(tempObj)) { + tempObj = pathObj[val] = {}; + } + var tempUrlObj = tempObj[url]; + if(isEmpty(tempUrlObj)) { + tempUrlObj = tempObj[url] = {}; + } + var tempPath = projectTreeIdIndex + url + "." + method; + tempUrlObj[method] = source[method]; + tempUrlObj[method].path = tempPath; + tempUrlObj[method].url = url; + tempUrlObj[method].method = method; + tempUrlObj[method].domain = domain; + treePathDataMap.set(tempPath, source[method]); + }); +} + +/** + * 将对象列表递归的方式转换成文档格式html字符串 + * @param pathData 处理后的对象列表 + * @returns 生成的html字符串 + */ +function getTreeHtmlForTag(pathData, treeIdStr) { + var tempStr = ""; + var indexNow = 1; + // get, head, post, put, patch, delete, options, trace + var actionArrays = ["get", "head", "post", "put", "patch", "delete", "options", "trace"]; + Object.keys(pathData).forEach(function(key){ + var tempNode = pathData[key]; + var tempTreeId = treeIdStr + "_" + indexNow; + // 只有一个子元素,而且有method元素,说明是只有一个节点 + var nodeSub = getObjectFirstAttributeIfOnly(tempNode); + if(nodeSub != null && isNotEmpty(nodeSub.method)) { + var summary = isEmpty(nodeSub.summary) ? "" : "(" + nodeSub.summary + ")"; + if(summary.length > 10){ + summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字 + } + nodeSub.treeId = tempTreeId; + tempStr += '
  • '+key+''+summary+'
  • '; + } else if(haveString(actionArrays, key)) { + //console.log(tempTreeId); + tempNode.treeId = tempTreeId; + var summary = isEmpty(tempNode.summary) ? "" : "("+tempNode.summary+")"; + if(summary.length > 10){ + summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字 + } + tempStr += '
  • '+key+''+summary+'
  • '; + } else { + tempStr += '
  • '; + tempStr += ''+key+''; + tempStr += ''; + tempStr += '
  • '; + } + indexNow++; + }); + return tempStr; +} + diff --git a/zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/mg-ui-tag.js b/zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/mg-ui-tag.js index e612f003..d07c903a 100644 --- a/zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/mg-ui-tag.js +++ b/zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/mg-ui-tag.js @@ -62,7 +62,7 @@ function createTreeViewByTag(json, keywords) { * @returns */ function setRequestMethodForTag(rewriteDomainUrl, domain, source, pathObj, url, method) { - if (isEmpty(source[method])) { + if (isEmpty(source[method]) || !source[method].tags) { return; } source[method].tags.forEach(function(val, index) {