-
Notifications
You must be signed in to change notification settings - Fork 156
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
Empty kwargs when implementing the example code from the docs #220
Comments
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 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 127.0.0.1 - - [21/Aug/2021 23:25:55] "GET /pets HTTP/1.1" 500 -
[2021-08-21 23:26:34,958] ERROR in app: Exception on /pets [GET]
Traceback (most recent call last):
...
File "/tmp/tmp.1QoI54ellk/./app.py", line 12, in list_pets
assert False, kwargs # NO DATA HERE
AssertionError: {'species': 'foo'} 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 @use_kwargs({'species': fields.Str()}, location='querystring') In which case the cURL request... curl -G 'http://localhost:5000/pets?species=foo' Now works as you would expect. |
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: