@redocly/cli
Version:
[@Redocly](https://redocly.com) CLI is your all-in-one API documentation utility. It builds, manages, improves, and quality-checks your API descriptions, all of which comes in handy for various phases of the API Lifecycle. Create your own rulesets to make
26 lines • 1.21 kB
JavaScript
import { COMPONENTS } from '../../split/types.js';
import { addPrefix } from './add-prefix.js';
export function collectComponents({ joinedDef, openapi, context, }) {
const { api, potentialConflicts, componentsPrefix } = context;
const { components } = openapi;
if (components) {
if (!joinedDef.hasOwnProperty(COMPONENTS)) {
joinedDef[COMPONENTS] = {};
}
for (const [component, componentObj] of Object.entries(components)) {
if (!potentialConflicts[COMPONENTS].hasOwnProperty(component)) {
potentialConflicts[COMPONENTS][component] = {};
joinedDef[COMPONENTS][component] = {};
}
for (const item of Object.keys(componentObj)) {
const componentPrefix = addPrefix(item, componentsPrefix);
potentialConflicts.components[component][componentPrefix] = [
...(potentialConflicts.components[component][item] || []),
{ [api]: componentObj[item] },
];
joinedDef.components[component][componentPrefix] = componentObj[item];
}
}
}
}
//# sourceMappingURL=collect-components.js.map