diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html
index 0a067862..1e2fe5b2 100644
--- a/lib/components/MethodsList/methods-list.html
+++ b/lib/components/MethodsList/methods-list.html
@@ -1,4 +1,8 @@
-
+
diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js
index dc04f4cf..72ee2545 100644
--- a/lib/components/MethodsList/methods-list.js
+++ b/lib/components/MethodsList/methods-list.js
@@ -21,18 +21,20 @@ export default class MethodsList extends BaseComponent {
// duplicate methods
let menuStructure = this.schemaMgr.buildMenuTree();
- let methods = Array.from(menuStructure.entries())
+ let tags = Array.from(menuStructure.entries())
.map((entry) => {
- let [tag, methods] = entry;
+ let [tag, {description, methods}] = entry;
// inject tag name into method info
methods.forEach(method => {
method.tag = tag;
});
- return methods;
- })
- // join arrays
- .reduce((a, b) => a.concat(b));
- this.data.methods = methods;
+ return {
+ name: tag,
+ description: description,
+ methods: methods
+ };
+ });
+ this.data.tags = tags;
// TODO: check $ref field
}
}
diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js
index 8df9c563..a4d70a48 100644
--- a/lib/components/SideMenu/side-menu.js
+++ b/lib/components/SideMenu/side-menu.js
@@ -121,7 +121,7 @@ export default class SideMenu extends BaseComponent {
prepareModel() {
this.data = {};
this.data.menu = Array.from(this.schemaMgr.buildMenuTree().entries()).map(
- el => ({name: el[0], methods: el[1]})
+ el => ({name: el[0], description: el[1].description, methods: el[1].methods})
);
}
diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js
index 87f7524f..1c6d750a 100644
--- a/lib/utils/SchemaManager.js
+++ b/lib/utils/SchemaManager.js
@@ -88,6 +88,13 @@ export default class SchemaManager {
/* returns ES6 Map */
buildMenuTree() {
let tag2MethodMapping = new Map();
+
+ let definedTags = this._schema.tags;
+ // add tags into map to preserve order
+ for (let tag of definedTags) {
+ tag2MethodMapping.set(tag.name, {description: tag.description});
+ }
+
let paths = this._schema.paths;
for (let path of Object.keys(paths)) {
let methods = Object.keys(paths[path]).filter((k) => swaggerMethods.has(k));
@@ -102,13 +109,13 @@ export default class SchemaManager {
let methodPointer = JsonPointer.compile(['paths', path, method]);
let methodSummary = methodInfo.summary;
for (let tag of tags) {
- let tagMethods = tag2MethodMapping.get(tag);
- if (!tagMethods) {
- tagMethods = [];
- tag2MethodMapping.set(tag, tagMethods);
+ let tagDetails = tag2MethodMapping.get(tag);
+ if (!tagDetails) {
+ tagDetails = {};
+ tag2MethodMapping.set(tag, tagDetails);
}
-
- tagMethods.push({pointer: methodPointer, summary: methodSummary});
+ if (!tagDetails.methods) tagDetails.methods = [];
+ tagDetails.methods.push({pointer: methodPointer, summary: methodSummary});
}
}
}