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

Automatically generate TypeScript types for all Pydantic models in a directory #52

Open
Fernichter opened this issue Jan 13, 2025 · 1 comment

Comments

@Fernichter
Copy link

Hi,

I’m currently using pydantic2ts to generate TypeScript types from my Pydantic models, and it works great when specifying a single module like:

pydantic2ts --module my_project.models.some_model --output ./types/some_model.ts

However, I have a directory (e.g., my_project/models/) containing many Python modules, each with multiple Pydantic models. I’d like to know if there’s a way to automatically generate TypeScript types for all Pydantic models in a directory or package, without manually specifying each module.

Does pydantic2ts support this functionality natively? Or would I need to implement this myself, e.g., by dynamically importing all models in the directory?

@phillipdupuis
Copy link
Owner

Hi, pydantic2ts doesn't currently support this functionality but I think it should be fairly simple to add. And it makes sense as a feature. I'll give it a try within the next few days.

I'll also allow --module to be specified multiple times, idk why I haven't done that before now

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

2 participants