Skip to content
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

Webargs not respecting preload hooks #426

Closed
multimeric opened this issue Sep 17, 2019 · 4 comments
Closed

Webargs not respecting preload hooks #426

multimeric opened this issue Sep 17, 2019 · 4 comments

Comments

@multimeric
Copy link

I'm attempting to use marshmallow-jsonapi with webargs. Now one of the key features of the jsonapi schemas is the pre-load hook that unwraps the data from {data: {...}} into {...}. However, it seems that webargs never runs the pre-load hooks. For this reason, converting my code from:

def post(self):
    data = SomeJsonApiSchema().load(request.json)    
    # Use data somehow

to

@use_args(SomeJsonApiSchema(), locations=('json',))
def post(self):
    # Use data somehow

does not work! It raises the error:

{'_schema': [{'detail': 'Object must include `data` key.', 'source': {'pointer': '/'}}]}

Now, it seems like we could easily run pre_dump hooks, if we loaded the entire input object in one go. However, we seem to re-parse the input data each time we need to parse a field, hence the need for the self._cache["json"] etc. Is there any reason for this? Why can't we get the entire input object as a dictionary, either from the query string, body, json etc?

@lafrech
Copy link
Member

lafrech commented Sep 17, 2019

Hopefully, this should be fixed by @sirosen's heroic refactor in #420.

@multimeric
Copy link
Author

Wow, it does indeed look heroic. I'll wait and see!

@lafrech
Copy link
Member

lafrech commented Jan 30, 2020

@TMiguelT would you like to check if this is fixed in webargs 6 beta ?

@lafrech
Copy link
Member

lafrech commented Feb 14, 2020

Closing as this should be fixed in 6.0.0 beta. Please reopen if it is not.

@lafrech lafrech closed this as completed Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants