TestBoxLab / chalice-spec

Chalice x APISpec x Pydantic plug-ins
MIT License
17 stars 7 forks source link

Add support for Pydantic V2 x OpenAPI 3 #22

Open Ali-Toosi opened 1 month ago

Ali-Toosi commented 1 month ago

Solves https://github.com/TestBoxLab/chalice-spec/issues/18

Pydantic V2 uses $defs key in its schema. This adds support for the new key while still working with the old definitions key.

Credit to https://github.com/kkirsche/apispec-pydantic-plugin and I think their repo should be integrated with this repo as it provides a more up-to-date Pydantic plugin for APISpec. But while that happens, it would be great if this fix could go forward to make it possible for the package to be used with Pydantic V2.

Additionally, this also fixes the tests not running. Pydantic does not allow calling the schema on the BaseModel directly, only on subclasses.