flask-restful-swagger icon indicating copy to clipboard operation
flask-restful-swagger copied to clipboard

Can support "Get" command with request body ?

Open dzhu622911 opened this issue 9 years ago • 4 comments

I am using flask-restful-swagger in my restful app, because my requirements have many parameters for different resources, so i want to put all of the params into request body of "Get" method (most of my app case is "Get" data).

i use curl to test my design, it works fine, just like: curl -i -H "Content-Type: application/json" -d "{"param1":"value1", "param2":"value2"}" -X GET localhost:5000/api/v1/resource

but when i use swagger UI to test, it looks fine, with body type parameters in UI, but it can't send the request body to my restful service (Receive None from request.json).

I know maybe the "query" paramType is suit for me, but i don't want to use query, because it will make a very long and complex URL.

The another option is "header" paramType, that could be a good choice, but current code (swagger 1.2 implementation) can't support header, right ?

Is there any possible method can meet my requirements or i need modify the swagger code ?

dzhu622911 avatar Jan 07 '16 09:01 dzhu622911

Get does not allow post parameters. So if you are using http GET you can not use a body.

lukas-gitl avatar Jan 07 '16 17:01 lukas-gitl

I would have to recommend using POST, especially if you really want to send JSON, as that's the use case it's designed for.

niall-byrne avatar Jan 07 '16 17:01 niall-byrne

I have used POST already, so it seems POST is the only choice

dzhu622911 avatar Jan 08 '16 10:01 dzhu622911

Once we are able to start implementing newer features like the "header" paramType, you'll have more options- thanks for flagging this as an issue.

niall-byrne avatar Jan 08 '16 19:01 niall-byrne