-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support for both Pydantic V1 and V2 #38
Conversation
I just added support for computed fields, and a corresponding test. |
Just looking through
The complexity of supporting both versions seems excessive to me. Wouldn't this library be better just releasing a Any reason I'm missing for supporting both |
There's a lot of Pydantic 1 using code out there that's not necessarily going to update, but could use this library. It doesn't seem to be very much extra code to support both (the majority of this PR's changes are test fixtures). |
@akx pydantic 1 using code can use v1 of this library right? |
I created a fork with this merged so the community can easily install it via pip. The code is published to PyPI as pydantic-to-typescript2. Phillip Dupuis is still included as an author. Repository link: Darius-Labs/pydantic-to-typescript2 |
Hi @phillipdupuis,
after switching to Pydantic V2 in one of my projects, this library stopped working.
To make sure that my changes are compatible with both, Pydantic V1 and V2, I created two virtual environments with each respective Pydantic version, and this library installed.
The initial goal was to keep the tests the same, but V2 requires slight adjustments to the inputs and generated outputs, which is why I created v1/v2-subdirectories for each type of test.
The changes that made that necessary were:
The library seems to work now with both, V1 and V2, by dynamically determining the installed Pydantic version and using the appropriate functions.