You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm sure you've moved on since you opened this issue; but since I just hit a similar issue, I'll post the resolution.
What the above example is missing, is that the use_kwargs decoration passes through its arguments to webargs' use_args decorator. use_args needs to know what location in the HTTP request it should pull args from. By default, it will check the request's body for JSON content. The project documentation is confusing, because it is using that default behavior for what is clearly a GET method - which is debatably nonsensical. It also doesn't help that the published docs are outdated, and the locations parameter has been renamed to location.
So your example application does actually work, if you send a JSON message body in a GET request, like so...
curl --header "Content-Type: application/json" --request GET --data '{"species":"foo"}' http://localhost:5000/pets
But that's kind of ridiculous. I assume you want to do the more sensible thing: embedding the kwargs in the query string. To make that work, you just need to specify location='querystring' in the use_kwargs params.
I have posted this issue to StackOverflow:
https://stackoverflow.com/questions/67574137/flask-apispec-not-populating-kwargs-with-values-from-get-query-implementation-o
The following simple program below, which is nearly identical to the example provided in the docs, does not work:
The
kwargs
field is empty.This is with flask v1.1.2.
The text was updated successfully, but these errors were encountered: