Closed C-Powers closed 2 years ago
Hi, thank you and I'm glad you like it! :)
So you're not missing anything -- pydantic-to-typescript
only finds and converts subclasses of pydantic.BaseModel
. It's intended for applications which use pydantic models for exchanging data with the outside world.
I think that extending it to convert non-pydantic classes (like stand-alone enums) would make the purpose of this package a bit less clear... probably result in a lot of bug reports asking "why is my .ts file filled with all these random types?" 😬
I can help you throw together a little script for converting standalone enums, if it helps! But I think that it is probably not something that will be an official feature
Hi @phillipdupuis, if you have an example script handy for converting enums that would be useful.
I understand not bloating the scope of your project. If we needed enums to be converted as well as Pydantic models, what would you recommend? I would prefer to avoid forking this package if possible - are there extensibility options we could explore?
Hey there, this package is really great, thanks so much!
It seems as though I'm not able to convert a standalone enum.
For example, I can convert my pydantic enums to a ts type like:
Where the converted enum type would look like:
And
EnumExample
will be properly converted. However, if I have a solo enum with no corresponding model, that will not be converted.Am I missing a step to get solo enums converted, or is this not yet a feature?
Thanks so much!