redoc/lib/components/MethodsList/methods-list.js

39 lines
1021 B
JavaScript
Raw Normal View History

2015-10-08 23:21:51 +03:00
'use strict';
import {RedocComponent, BaseComponent} from '../base';
2015-10-27 20:44:08 +03:00
import Method from '../Method/method';
2015-10-08 23:21:51 +03:00
@RedocComponent({
2015-10-08 23:21:51 +03:00
selector: 'methods-list',
templateUrl: './lib/components/MethodsList/methods-list.html',
2015-10-10 16:01:41 +03:00
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
directives: [Method]
2015-10-08 23:21:51 +03:00
})
2015-10-27 20:44:08 +03:00
export default class MethodsList extends BaseComponent {
2015-10-08 23:21:51 +03:00
constructor(schemaMgr) {
super(schemaMgr);
2015-10-08 23:21:51 +03:00
}
prepareModel() {
2015-10-08 23:21:51 +03:00
this.data = {};
// follow SwaggerUI behavior for cases when one method has more than one tag:
// duplicate methods
2015-10-08 23:21:51 +03:00
let menuStructure = this.schemaMgr.buildMenuTree();
let methods = Array.from(menuStructure.entries())
.map((entry) => {
let [tag, 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;
2015-10-10 15:34:46 +03:00
// TODO: check $ref field
2015-10-08 23:21:51 +03:00
}
}