Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Confusion around the type for included data. #133

@anthony-arnold

Description

@anthony-arnold

There seems to be a little confusion around the correct type for included data.

To quote the JSON API spec:

In a compound document, all included resources MUST be represented as an array of resource objects in a top-level included member.

In marshmalllow_jsonapi.schema.Schema.__init__, the included_data member is initialised as a dict.

In _do_load, the included_data member defaults to a dict. However, it is iterated as a list inside _extract_from_included which would be correct. This works if the payload is an array or undefined, because then _extract_from_included will either iterate the list or iterate the keys of an empty dict.

In render_included_data, the included_data member is expected to have a values method (i.e. dict-like).

The reason I think this has been working so far is because most people are not deserialising payloads with 'included' data. This is because the current spec has no provision for compound document requests (but there are some in draft), only responses.

The spec clearly states the the top-level included member is an array. It should be treated as a list everywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions