@whook/whook
Version:
Build strong and efficient REST web services.
44 lines • 1.49 kB
JavaScript
export const ASIDE_COMPONENTS_SUFFIXES = {
schemas: 'Schema',
parameters: 'Parameter',
headers: 'Header',
requestBodies: 'RequestBody',
responses: 'Response',
callbacks: 'Callback',
};
export const ASIDE_COMPONENTS_PROPERTIES = {
schemas: 'schema',
parameters: 'parameter',
headers: 'header',
requestBodies: 'requestBody',
responses: 'response',
callbacks: 'callback',
};
export function combineComponents({ log }, modules) {
const components = {
schemas: {},
parameters: {},
headers: {},
requestBodies: {},
responses: {},
callbacks: {},
};
for (const module of modules) {
for (const key in module) {
for (const type in ASIDE_COMPONENTS_PROPERTIES) {
if (key.endsWith(ASIDE_COMPONENTS_SUFFIXES[type])) {
const component = module[key];
if (components[type][component.name] &&
components[type][component.name] !==
component[ASIDE_COMPONENTS_PROPERTIES[type]]) {
log('warning', `⚠️ - Overriding an existing aside component (type: "${type}", name: "${component.name}").`);
}
components[type][component.name] =
component[ASIDE_COMPONENTS_PROPERTIES[type]];
}
}
}
}
return components;
}
//# sourceMappingURL=base.js.map