openverse-api icon indicating copy to clipboard operation
openverse-api copied to clipboard

Refactor serializers to match media models and ES indices

Open dhruvkb opened this issue 4 years ago • 0 comments

Description

  • Clean up the use of validations such as allow_null, allow_blank and required in 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 Hit when searching but for Media subclasses when retrieving details. This can cause issues due to Hit fields being a subset of those in Media.
    • 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.

dhruvkb avatar Oct 15 '21 05:10 dhruvkb