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

[ts-to-oapi] Imported types are transformed #21

Closed
enzoferey opened this issue Mar 26, 2022 · 3 comments
Closed

[ts-to-oapi] Imported types are transformed #21

enzoferey opened this issue Mar 26, 2022 · 3 comments

Comments

@enzoferey
Copy link

enzoferey commented Mar 26, 2022

Whenever you are transforming a TypeScript file to an OpenApi specification file, if you declare a type that reuses some other type that you import from a different file, the imported types are not included in the OpenApi specification file.

As an example this file:

import type { MyTypeB } from "./some-file";

export type A = MyTypeB;

generates:

$ref: '#/components/schemas/MyTypeB'

however no MyTypeB component is generated inside the file.

@menocomp
Copy link

menocomp commented Jan 22, 2023

I had a look at the readme file and it says:

typeconv doesn't support external references (to other files). If you have that, you need to use a reference parser and merge it into one inline-referenced file before using typeconv.

I have the same issue and not sure yet if I should squash types into one file, or run typeconv once per each file and collect the schemas via a program. Both options look difficult to do.

@grantila
Copy link
Owner

Right, I'll have to close this as simple not supported.

Merging typescript files into one is not just concatenating them, it requires language-level logic to do it right, so it makes more sense for other packages out there to do that job. Have a look at https://www.npmjs.com/package/dts-bundle-generator or https://www.npmjs.com/package/dts-generator they do precisely this.

@enzoferey
Copy link
Author

enzoferey commented Jan 22, 2023

Thanks for the references and explanations @menocomp @grantila ! This was a long time ago so I can't remember if the README was stating that at the time or not. If so, I'm sorry 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants