json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

[BUG] Input coming from pipe not processed

Open Zubnix opened this issue 4 years ago • 1 comments

cat schema.json | json2ts produces an empty file (just some comments) json2ts schema.json works as expected.

Zubnix avatar Apr 27 '21 11:04 Zubnix

I've experienced something similar. From looking at the source code, it seems in order for the Typescript type to be generated fully, it needs a value for the name parameter in compile(), which is undefined when using stdin. If my assessment is correct, then maybe cli.ts needs to support passing in a name which can use to then generate the full type or at least use a default (I see 'NoName' somewhere in there).

https://github.com/bcherny/json-schema-to-typescript/blob/8ea10a61f0d4b24749ae033a37f9aa3fb9a94417/src/index.ts#L112

aahventures avatar May 05 '21 19:05 aahventures