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
Similar to the id field, I have a created_on field the database will auto create for me. Now, what is the best way to not allow the field in POST, PUT but have it in GETs?
Require the use of Create and Update Schema. Nothing would need to change, but all that schema creation smells of boilerplate.
Modify the _utils.py schema_factory to allow for additional fields to exclude. However, at that point you might as well add id to that list and make it generic.
Modify the _utils.py schema_factory to look for allow_mutation and exclude it along with id.
for f in schema_cls.__fields__.values()
if f.name != pk_field_name and f.field_info.allow_mutation
Now my field could look something like
# Not in OpenAPI post or put
update_on: datetime.datetime = Field(
allow_mutation=False, description="Last update from sync system"
)
Is there a better way to remove fields from Create and Update schemas easily?
The text was updated successfully, but these errors were encountered:
I totally agree with what you suggested. I think removing fields with allow_mutation=false in the schema factory would be a great way of reducing potential boiler plate. 🚀
Is this something you would be interested in PRing?
Similar to the
id
field, I have acreated_on
field the database will auto create for me. Now, what is the best way to not allow the field in POST, PUT but have it in GETs?id
to that list and make it generic.allow_mutation
and exclude it along withid
.Now my field could look something like
Is there a better way to remove fields from Create and Update schemas easily?
The text was updated successfully, but these errors were encountered: