Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support partial config in createGenerator #1919

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions factory/generator.ts
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 2 additions & 3 deletions ts-json-schema-generator.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand Down
Loading