openverse-api
openverse-api copied to clipboard
Refactor serializers to match media models and ES indices
Description
-
Clean up the use of validations such as
allow_null,allow_blankandrequiredin serializers:- Some serializers are used for deserializing input text to data and some for serializing data to JSON. The validations mean different things during serialization and deserialization.
- The same serializer is used for
Hitwhen searching but forMediasubclasses when retrieving details. This can cause issues due toHitfields being a subset of those inMedia. - These validations, which are currently undocumented, can be cleaned up and their use can be documented.
-
Since the serializers are not structured in correspondence to the mixins making up media classes, they tend to go out of sync when the Django models are migrated or when ES indices change.
Expectation
Validations should be used cautiously and with documentation so that they can stay up to date with changes to Media (made by Django model migrations) or changes to Hit (made by changes to ES indices).
Resolution
- [ ] 🙋 I would be interested in resolving this bug.