swagger查看页面的各种优化,替换首页原有文档入口
This commit is contained in:
@@ -7,10 +7,10 @@ const methodArray = ["get", "head", "post", "put", "patch", "delete", "options",
|
||||
* @returns {{pathDataMap: {}, pathData: {}}}
|
||||
*/
|
||||
export function createTreeViewByTag(swagger, keywords) {
|
||||
let pathData = {}, pathDataMap = {};
|
||||
let pathData = {}, pathDataMap = {}, methodStatistic = {};
|
||||
let swaggerPaths = swagger.paths;
|
||||
if (!swaggerPaths) {
|
||||
return {pathDataMap, pathData};
|
||||
return {pathDataMap, pathData, methodStatistic};
|
||||
}
|
||||
//console.log(swaggerPaths);
|
||||
Object.keys(swaggerPaths).forEach(url => {
|
||||
@@ -20,6 +20,9 @@ export function createTreeViewByTag(swagger, keywords) {
|
||||
if (!pathMethods[method] || !pathMethods[method].tags) {
|
||||
continue;
|
||||
}
|
||||
let methodUp = method.toUpperCase();
|
||||
methodStatistic[methodUp] = (methodStatistic[methodUp] || 0) + 1;
|
||||
methodStatistic['TOTAL'] = (methodStatistic['TOTAL'] || 0) + 1;
|
||||
pathMethods[method].tags.forEach(tag => {
|
||||
let pathTag = pathData[tag];
|
||||
if (!pathTag) {
|
||||
@@ -39,7 +42,7 @@ export function createTreeViewByTag(swagger, keywords) {
|
||||
});
|
||||
}
|
||||
});
|
||||
return {pathData, pathDataMap};
|
||||
return {pathData, pathDataMap, methodStatistic};
|
||||
}
|
||||
|
||||
export function getTreeDataForTag(swagger, pathData, metaInfo) {
|
||||
|
||||
@@ -10,6 +10,7 @@ export default createStore({
|
||||
swaggerDoc: {},
|
||||
swaggerDefinitions: {},
|
||||
swaggerTreePathMap: {},
|
||||
methodStatistic: {},
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
@@ -26,6 +27,9 @@ export default createStore({
|
||||
setSwaggerTreePathMap(state, swaggerTreePathMap) {
|
||||
state.swaggerTreePathMap = swaggerTreePathMap;
|
||||
},
|
||||
setMethodStatistic(state, methodStatistic) {
|
||||
state.methodStatistic = methodStatistic;
|
||||
},
|
||||
addTableName(state, item) {
|
||||
let sameObj = Object.assign({}, state.pageTabNameMap);
|
||||
sameObj[item.key] = item.val;
|
||||
|
||||
Reference in New Issue
Block a user