-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix included_data and data["included"] type consistency. #268
base: dev
Are you sure you want to change the base?
Fix included_data and data["included"] type consistency. #268
Conversation
included resource objects in the json api is a list but the schema implementation needs it to be a dict indexed by type and id. The new test checks that loading and then dumping with the same schema object on a dict with an included resource works. It is needed for Flask-rest-jsonapi that re-uses schema between load and dump.
tests/test_schema.py
Outdated
{ | ||
"type": "people", | ||
"id": "1", | ||
"first_name": fake.first_name(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These attributes should be inside the "attributes": {}
key. I'm a tad surprised that this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected in the last commit
I will response here to #133 (comment) Schema.included_data is consistently a dict for loading and dumping. And the "included" part of the json api object is consistently a list. |
The included resource objects in the json api are in a list but the schema implementation
needs it to be a dict indexed by type and id.
The new test checks that loading and then dumping with the same schema object on a
dict with an included resource works. It is needed for Flask-rest-jsonapi that re-uses schema between load and dump.