0b01001001 / spectree

API spec validator and OpenAPI document generator for Python web frameworks.
https://0b01001001.github.io/spectree/
Apache License 2.0
324 stars 75 forks source link

feat: add an abstract layer to support pydantic/msgspec #329

Open kemingy opened 1 year ago

kemingy commented 1 year ago

Pydantic v2 has too many breaking changes that lots of 3rd libraries are not able to upgrade in a short time.

This PR is not backward compatible (due to pydantic breaking changes). I'm not sure if we should make this library compatible with both pydantic v1 & v2. Or maybe we should add another abstract layer so that we can make it possible to support pydantic v1 & v2 and msgspec (ref #307)

Originally posted by @kemingy in https://github.com/0b01001001/spectree/pull/319#pullrequestreview-1510211443

BradLucky commented 3 weeks ago

Is this issue/repo still getting attention? This is over a year old at this point. I managed to copy GenericModel from Pydantic, making it so that SpecTree can still be used with dependency on Pydantic V1 even though we are running V2. SpecTree has been great for us, but if it will not be getting true support for V2, I'm afraid I'll have to remove the dependency and find another solution.

That said, if I find some extra free time, I might give it a go to fulfill this issue.

kemingy commented 3 weeks ago

Is this issue/repo still getting attention? This is over a year old at this point. I managed to copy GenericModel from Pydantic, making it so that SpecTree can still be used with dependency on Pydantic V1 even though we are running V2. SpecTree has been great for us, but if it will not be getting true support for V2, I'm afraid I'll have to remove the dependency and find another solution.

I didn't find a good solution at that time. Also, I have tried another general OpenAPI doc only solution in defspec. I wonder if I can reuse the code.

That said, if I find some extra free time, I might give it a go to fulfill this issue.

I can also find some free time. It would be very helpful if you could leave some comments about the rough ideas here. I haven't been using pydantic for a while.

kemingy commented 3 days ago

387 makes it possible to support both pydantic v1 & v2.