mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-30 04:23:44 +03:00
Add warnings for non-used or non-existing tags in groups
This commit is contained in:
parent
dd188d6fe0
commit
0d3580e21f
|
@ -295,18 +295,29 @@ export class MenuService {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTagsItems(parent: MenuItem, tagsGroup:string[] = null):MenuItem[] {
|
getTagsItems(parent: MenuItem, tagGroup:TagGroup = null):MenuItem[] {
|
||||||
let schema = this.specMgr.schema;
|
let schema = this.specMgr.schema;
|
||||||
|
|
||||||
if (!tagsGroup) {
|
let tags;
|
||||||
|
if (!tagGroup) {
|
||||||
// all tags
|
// all tags
|
||||||
tagsGroup = Object.keys(this._tagsWithMethods);
|
tags = Object.keys(this._tagsWithMethods);
|
||||||
|
} else {
|
||||||
|
tags = tagGroup.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tags = tagsGroup.map(k => this._tagsWithMethods[k]);
|
tags = tags.map(k => {
|
||||||
|
if (!this._tagsWithMethods[k]) {
|
||||||
|
console.warn(`Non-existing tag "${k}" is specified in tag group "${tagGroup.name}"`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
this._tagsWithMethods[k].used = true;
|
||||||
|
return this._tagsWithMethods[k];
|
||||||
|
});
|
||||||
|
|
||||||
let res = [];
|
let res = [];
|
||||||
for (let tag of tags || []) {
|
for (let tag of tags || []) {
|
||||||
|
if (!tag) continue;
|
||||||
let id = 'tag/' + slugify(tag.name);
|
let id = 'tag/' + slugify(tag.name);
|
||||||
let item: MenuItem;
|
let item: MenuItem;
|
||||||
|
|
||||||
|
@ -344,12 +355,21 @@ export class MenuService {
|
||||||
isGroup: true,
|
isGroup: true,
|
||||||
items: null
|
items: null
|
||||||
};
|
};
|
||||||
item.items = this.getTagsItems(item, group.tags);
|
item.items = this.getTagsItems(item, group);
|
||||||
res.push(item);
|
res.push(item);
|
||||||
}
|
}
|
||||||
|
this.checkAllTagsUsedInGroups();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkAllTagsUsedInGroups() {
|
||||||
|
for (let tag of Object.keys(this._tagsWithMethods)) {
|
||||||
|
if (!this._tagsWithMethods[tag].used) {
|
||||||
|
console.warn(`Tag "${tag}" is not added to any group`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildMenu() {
|
buildMenu() {
|
||||||
this._tagsWithMethods = SchemaHelper.getTagsWithMethods(this.specMgr.schema);
|
this._tagsWithMethods = SchemaHelper.getTagsWithMethods(this.specMgr.schema);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user