Skip to content

Commit

Permalink
making tags as a set to remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
RoshniNaveenaS committed Oct 17, 2024
1 parent e3e61a2 commit 7ff069f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/compile/csdl2openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,18 +496,19 @@ module.exports.csdl2openapi = function (
* @return {Array} The list of tags
*/
function getTags(container) {
const tags = [];
// all entity sets and singletons
Object.keys(container).filter(name => isIdentifier(name) && container[name].$Type).forEach(child => {
const type = modelElement(container[child].$Type) || {};
const tag = {
name: type[voc.Common.Label] || child
};
const description = container[child][voc.Core.Description] || type[voc.Core.Description];
if (description) tag.description = description;
tags.push(tag);
})
return tags.sort(function (pre, next) { return pre.name.localeCompare(next.name) });
const tags = new Map();
Object.keys(container)
.filter(name => isIdentifier(name) && container[name].$Type)
.forEach(child => {
const type = modelElement(container[child].$Type) || {};
const tag = {
name: type[voc.Common.Label] || child
};
const description = container[child][voc.Core.Description] || type[voc.Core.Description];
if (description) tag.description = description;
tags.set(tag.name, tag);
});
return Array.from(tags.values()).sort((pre, next) => pre.name.localeCompare(next.name));
}

/**
Expand Down

0 comments on commit 7ff069f

Please sign in to comment.