You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use typegen on some swagger.yaml files.
Those API definitions leverage remote/local reference (e.g. $ref: "path/to/entity") a lot, to minimize duplication of codes.
As far as I tested, typegen works finely with such remote/local references, ... except references in responses fields 😭
Those API definitions work finely with other Swagger-based tools (e.g. Swagger editor and Redoc), so I suspect this is an issue in openali-client-axios-typegen.
versions
typegen: 1.0.7
What happend
The below is a reproducible swagger file definitions.
Then, run typegen swagger.yaml > foo.d.ts and we will got
(node:630) UnhandledPromiseRejectionWarning: Error: The $ref targets root is not found: #/paths/~1login/post/responses/503/content/application~1json/schema/properties/errors/items
at ReferenceResolver.<anonymous> (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/referenceResolver.js:105:35)
at step (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/tslib/tslib.js:136:27)
at Object.next (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/tslib/tslib.js:117:57)
at /usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/tslib/tslib.js:110:75
at new Promise (<anonymous>)
at Object.__awaiter (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/tslib/tslib.js:106:16)
at ReferenceResolver.resolve (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/referenceResolver.js:26:24)
at DtsGenerator.<anonymous> (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:22:50)
at step (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/tslib/tslib.js:136:27)
at Object.next (/usr/local/lib/node_modules/openapi-client-axios-typegen/node_modules/tslib/tslib.js:117:57)
Note
I observed some cases where typegen runs successfully with references on some cases.
Case 1. Limit the occurence of remote reference in responses to 1.
Hi @exoego. Sorry for such a late response. This seems like a bug in the underlying https://github.com/horiuchi/dtsgenerator library. Unfortunately there's not much we can do on typegen side.
Thanks for investigating.
Grad to see someone is working on dtsgenearator. horiuchi/dtsgenerator#414
I will suggest to keep this issue open until dtsgenerator support that.
This is a bug report.
Thanks for creating great library 👍
I am trying to use
typegen
on some swagger.yaml files.Those API definitions leverage remote/local reference (e.g.
$ref: "path/to/entity"
) a lot, to minimize duplication of codes.As far as I tested,
typegen
works finely with such remote/local references, ... except references inresponses
fields 😭Those API definitions work finely with other Swagger-based tools (e.g. Swagger editor and Redoc), so I suspect this is an issue in
openali-client-axios-typegen
.versions
What happend
The below is a reproducible swagger file definitions.
We prepare 2 files.
swagger.yaml
shared-api-components.yaml
Then, run
typegen swagger.yaml > foo.d.ts
and we will gotNote
I observed some cases where
typegen
runs successfully with references on some cases.Case 1. Limit the occurence of remote reference in
responses
to1
.In swagger.yaml,
But this is not desirable, since I want to use remote reference/local reference to minimize code duplication.
Case 2. Limit the occurence of same local reference in external files to
1
.In
shared-api-components.yaml
, changed like belowBut this is not desirable, since I want to use remote reference/local reference to minimize code duplication.
The text was updated successfully, but these errors were encountered: