Files
fastapi-openapi-to-postman/lib/bundleRules/resolvers.js
Erik Mendoza 183bc1eb27 Refactor rule resolver 3.0 and 3.1
- Moving each bundling version rules to new files
- Removing componentsParentMatcher files
- Replacing the getKeyInComponents for each version by a generalized one
- Adding a method to get the version bundling data by version
- Replacing the new sources in files
2022-06-16 00:41:49 -05:00

34 lines
933 B
JavaScript

module.exports = {
/**
* Resolve the scenario if the item is in second level
* @param {array} trace The keyInComponents
* @param {number} index the current index
* @return {undefined}
*/
resolveSecondLevelChild: function (trace, index, definitions) {
const item = definitions[trace[index + 2]];
if (item) {
trace[index + 1] = item;
}
},
/**
* If the provided item is included in any defined container it returns the container name
* else it return the same item
* @param {string} item The current item in the iteration
* @returns {string} the name of container where item is included or the item if it's not included
* in any container
*/
resolveFirstLevelChild: function(item, containers) {
for (let [key, containerItems] of Object.entries(containers)) {
if (containerItems.includes(item)) {
return key;
}
}
return item;
}
};