diff --git a/factory/generator.ts b/factory/generator.ts index 1156237d2..8c36666f6 100644 --- a/factory/generator.ts +++ b/factory/generator.ts @@ -1,13 +1,14 @@ -import { CompletedConfig } from "../src/Config"; +import { Config, DEFAULT_CONFIG } from "../src/Config"; import { SchemaGenerator } from "../src/SchemaGenerator"; import { createFormatter } from "./formatter"; import { createParser } from "./parser"; import { createProgram } from "./program"; -export function createGenerator(config: CompletedConfig): SchemaGenerator { - const program = createProgram(config); - const parser = createParser(program, config); - const formatter = createFormatter(config); +export function createGenerator(config: Config): SchemaGenerator { + const completedConfig = { ...DEFAULT_CONFIG, ...config }; + const program = createProgram(completedConfig); + const parser = createParser(program, completedConfig); + const formatter = createFormatter(completedConfig); - return new SchemaGenerator(program, parser, formatter, config); + return new SchemaGenerator(program, parser, formatter, completedConfig); } diff --git a/ts-json-schema-generator.ts b/ts-json-schema-generator.ts index c0cb4f7e6..afc31143e 100644 --- a/ts-json-schema-generator.ts +++ b/ts-json-schema-generator.ts @@ -1,7 +1,7 @@ import { Command, Option } from "commander"; import stableStringify from "safe-stable-stringify"; import { createGenerator } from "./factory/generator"; -import { CompletedConfig, DEFAULT_CONFIG } from "./src/Config"; +import { Config } from "./src/Config"; import { BaseError } from "./src/Error/BaseError"; import { formatError } from "./src/Utils/formatError"; import * as pkg from "./package.json"; @@ -53,8 +53,7 @@ const args = new Command() .parse(process.argv) .opts(); -const config: CompletedConfig = { - ...DEFAULT_CONFIG, +const config: Config = { minify: args.minify, path: args.path, tsconfig: args.tsconfig,