You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am evaluating Cadwyn as an option for my API to enable versioning. Many of my application routes use a paginated response model using FastAPI-Pagination, and in these cases the response model is wrapped with / nested in a "Page" model that exists outside of my head schemas package. In my route I will query for data using Beanie, and then project the response.
I wanted to get an understanding about version migrations so I made a very simple change to the CustomerBase schema by adding an address field, and I wanted to test whether I could enforce that field to be present only in newer API versions. I added a address field to my CustomerBase in the head package, and added a version change to specify that the field did not previously exist.
This works fine for the get_customer route. In the older API version the address is not present in the response, and in the newer version the address is present in the response. But, the list_customers route which uses a wrapped response model includes the address field in both versions.
My assumption here is that because my version change migration is applied to CustomerBase and not Page[CustomerBase] the migration is not getting applied.
The paginated response in the old version looks like:
My question is whether this type of migration is supported with Cadwyn? Is it possible to provide migration instructions for schemas that are wrapped with another schema (in this case the Page) which exist outside of my head package?
The text was updated successfully, but these errors were encountered:
I am afraid that the migration of internal schemas within external schemas is not supported yet. In fact, migrating generic response models might also be hard right now. Additionally, adding an address to the response is not a breaking change so I would recommend to just add it into all versions.
I am currently drafting a feature that would add support for external schemas but it won't be ready any time soon, sadly. I recommend implementing those classes internally
Is your feature request related to a problem? Please describe.
I am evaluating Cadwyn as an option for my API to enable versioning. Many of my application routes use a paginated response model using FastAPI-Pagination, and in these cases the response model is wrapped with / nested in a "Page" model that exists outside of my
head
schemas package. In my route I will query for data using Beanie, and then project the response.Consider the below demo project:
demo.schemas.head.customer.py:
demo.routes.customer.py:
I wanted to get an understanding about version migrations so I made a very simple change to the CustomerBase schema by adding an
address
field, and I wanted to test whether I could enforce that field to be present only in newer API versions. I added aaddress
field to my CustomerBase in thehead
package, and added a version change to specify that the field did not previously exist.demo.versions.v2024_05_31.py:
This works fine for the
get_customer
route. In the older API version the address is not present in the response, and in the newer version the address is present in the response. But, thelist_customers
route which uses a wrapped response model includes theaddress
field in both versions.My assumption here is that because my version change migration is applied to CustomerBase and not Page[CustomerBase] the migration is not getting applied.
The paginated response in the old version looks like:
And when using the
get_customer
route (non-paginated) I see the expected response after migration.My question is whether this type of migration is supported with Cadwyn? Is it possible to provide migration instructions for schemas that are wrapped with another schema (in this case the Page) which exist outside of my head package?
The text was updated successfully, but these errors were encountered: