-
Notifications
You must be signed in to change notification settings - Fork 68
Confusion around the type for included data. #133
Comments
OK, with a little more investigation it seems that during During The main problem arises when you use the same I think that |
This bug arises when using flask-rest-jsonapi. I've done a correction to have a consistent type for included_data. Pull request coming soon. |
The promised pull request: #268 |
So if I understand right, the behaviour is consistent for each task: when dumping, @AdrianVandierAst if you write "closes X" anywhere in a comment on your PR, it will link them: https://help.github.com/en/github/managing-your-work-on-github/closing-issues-using-keywords#about-issue-references |
There seems to be a little confusion around the correct type for included data.
To quote the JSON API spec:
In
marshmalllow_jsonapi.schema.Schema.__init__
, theincluded_data
member is initialised as a dict.In
_do_load
, theincluded_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
, theincluded_data
member is expected to have avalues
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.
The text was updated successfully, but these errors were encountered: