ts-json-schema-generator icon indicating copy to clipboard operation
ts-json-schema-generator copied to clipboard

output multiple files, in place?

Open srsudar opened this issue 6 months ago • 8 comments

I'm working on a big project. It compiles using TSC to .d.ts files (see #2215).

However, when trying to run the ts-json-schema-generator on the .d.ts files, I am regularly getting errors that I seem to have hit the max string size:

<snip>/ts-json-schema-generator/ts-json-schema-generator.ts:82
    const schemaString = (config.minify ? stringify(schema) : stringify(schema, null, 2)) as string;
                                                              ^


RangeError: Invalid string length
    at stringify (<anonymous>)
    at stableStringify (<snip>/ts-json-schema-generator/ts-json-schema-generator.ts:82:63)
    at Object.<anonymous> (<snip>/ts-json-schema-generator/ts-json-schema-generator.ts:108:1)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Object.transformer (<snip>/ts-json-schema-generator/node_modules/tsx/dist/register-DCnOAxY2.cjs:2:1186)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:203:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)

Is there a way to instead of putting the schema in a single large file, instead have it generate smaller schema files? If I had Foo.d.ts and Bar.d.ts, eg, I'd be happy to have Foo.schema.json and Bar.schema.json, and have them reference each other using relative paths.

Apologies if this is already supported somehow in a way that I'm missing.

srsudar avatar Apr 06 '25 18:04 srsudar