mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-27 02:53:43 +03:00
39 lines
1015 B
JavaScript
39 lines
1015 B
JavaScript
'use strict';
|
|
|
|
import {RedocComponent, BaseComponent} from '../base';
|
|
import {Method} from '../Method/method';
|
|
|
|
@RedocComponent({
|
|
selector: 'methods-list',
|
|
templateUrl: './lib/components/MethodsList/methods-list.html',
|
|
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
|
|
directives: [Method]
|
|
})
|
|
export class MethodsList extends BaseComponent {
|
|
|
|
constructor(schemaMgr) {
|
|
super(schemaMgr);
|
|
}
|
|
|
|
prepareModel() {
|
|
this.data = {};
|
|
// follow SwaggerUI behavior for cases when one method has more than one tag:
|
|
// duplicate methods
|
|
|
|
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;
|
|
// TODO: check $ref field
|
|
}
|
|
}
|