Skip to content

Refactoring: Serializers #32

Open
Open
@reva2

Description

@reva2

Hi guys,

Currently, code that parse responses and generate payloads for requests spread out between two components JsonApiDatastore and JsonApiModel. This cause unnecessary complexity of each component and high coupling between them. Code is a bit messy and it hard to test it. Also it's not flexible because end user couldn't change any parts of data handling process.

I think that we should refactor this code to series of separate components - serializers. We should have three types of serializers:

  • ResponseSerializer - it should be able to convert response data to DocumentModel (see Support for more general json:api documents (links, data, meta) #26). Under hood it should use models serializers (see below) to convert separate resources.
  • RequestSerializer - it should be able to convert specified JsonApiModel to request payload. Again, under hood it should use models serializers to convert separate resource.
  • ModelSerializer - it should support two things: unserialize part of response data to JsonApiModel instance and serialize JsonApiModel instance into part of request payload.

All serializers should be configurable. I.e. we need to support following scenarios:

  • user should be able to replace default response, request and model serializers
  • user should be able to use cumstom serializer for specific JsonApiModel

Please let me know what you think about it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions