import { adapterOas } from '@kubb/adapter-oas' import { cliReporter, fileReporter, htmlReporter, jsonReporter, type UserConfig } from '@kubb/core' import { parserMd } from '@kubb/parser-md' import { parserTs, parserTsx } from '@kubb/parser-ts' import { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel' /** * Fills what a user config leaves out: `adapterOas()`, the TypeScript, TSX and Markdown parsers, the reporters, * `pluginBarrel()`, and `false` for `output.barrel`, `output.format` and `output.lint`. */ export function applyDefaults(config: UserConfig): UserConfig { const plugins = config.plugins ?? [] return { ...config, adapter: config.adapter ?? adapterOas(), parsers: config.parsers?.length ? config.parsers : [parserTs(), parserTsx(), parserMd()], reporters: config.reporters?.length ? config.reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter], plugins: plugins.some((plugin) => plugin.name === pluginBarrelName) ? plugins : [...plugins, pluginBarrel()], output: { barrel: false, format: false, lint: false, ...config.output }, } }