fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 23 lines 700 B view raw
1import { valueToObject } from '../../utils/config'; 2import type { SourceConfig, UserSourceConfig } from './types'; 3 4export function resolveSource(config: { source?: boolean | UserSourceConfig }): SourceConfig { 5 const source = valueToObject({ 6 defaultValue: { 7 enabled: Boolean(config.source), 8 extension: 'json', 9 fileName: 'source', 10 serialize: (input) => JSON.stringify(input, null, 2), 11 }, 12 mappers: { 13 boolean: (enabled) => ({ enabled }), 14 }, 15 value: config.source, 16 }); 17 if (source.path === undefined || source.path === true) { 18 source.path = ''; 19 } else if (source.path === false) { 20 source.path = null; 21 } 22 return source as SourceConfig; 23}