Clinical-Genomics / cg

Glue between Clinical Genomics apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add separate layer of serialization logic

seallard opened this issue · comments

When deprecating alchy, we just ensured that the old expected functionality from alchy existed by adding a to_dict method on all our models (a single base to_dict method is used).

When adding a field, it is serialized by default in the response from any endpoint which includes the model. That is brittle and we can't control which data is returned in our endpoints.

Short term fix

Define an explicit to_dict method on each model, only including the required fields.

Long term fix

Add a separate layer, maybe using a package like marshmallow/pydantic or something similar, to have explicit control over which data is serialized and how in the responses from our endpoints.