Open Hulkmaster opened 4 years ago
i guess the reason is here https://github.com/bcherny/json-schema-to-typescript/blob/1ec105d1f00f23969bd057fe151ff952a7280e3d/src/index.ts#L64 https://github.com/APIDevTools/json-schema-ref-parser/blob/a4eec2ba56d793c410fb884a06f5eb9dfba4e412/lib/options.js#L32
so the solution will be to pass json
parser to ref-parser
that lib by default
also i'm not sure if its possible to pass it from cli
currently
We've run into this bug as well. It causes us some problems.
What are your thoughts on this @bcherny ?
Hey, sorry for the delayed response. Not sure I totally understand the issue -- mind spelling it out a bit more, and providing a complete, whittled down repro case?
When lib is trying to resolve references, it uses different parser
I would suggest to use recursive (using same lib) approach for resolving references
accidentally closed
So we have project with structure like
project/apidocs/entitity
project/apidocs/response
project/ts-apidocs/entitity
project/ts-apidocs/response
if we launch cli tool like
cd apidocs && json2ts -i ./response/**/*.json -o ../ts-apidocs
we have a file
./apidocs/response/Something.json
which has reference"$ref": "../entity/Something-2.json"
and our
something-2.json
has
required
properties, for example,id
if we would generate
Something-2.json
directly, then.ts
files will have property asrequired
but if type would be generates via$ref
, then property will be marked asoptional
so i guess direct converting and converting via
$ref
uses different rules, and$ref
converting has a bug