grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

File type param uses wrong name in both docs UI and when sending test request from docs.

Open atomless opened this issue 9 years ago • 6 comments

Grape swagger is working brilliantly for all my endpoints apart from this one that requires a File param. The grape api endpoint works fine and all params validate when I call the api from my own code but the auto generated swagger docs are not working right with this one param. Here's the param validation code:

params :requires_pdf_data do
    requires :data, type: Rack::Multipart::UploadedFile, desc: 'Mulitpart file upload accepts application/pdf'
end

And here's a screenshot of how swagger shows that param:

screenshot_07_01_2016_19_58

When I call the endpoint from my own code it works perfectly but from swagger it always says that the data param is missing. Is this a bug or am I missing something? Any ideas?

atomless avatar Jan 07 '16 20:01 atomless

Is there code in grape-swagger or swagger-ui that is wrongly labelling the param "body" when it's called "data" in the param validation?

atomless avatar Jan 08 '16 15:01 atomless

I would compare the HTTP requests next.

dblock avatar Jan 10 '16 14:01 dblock

@dblock Hi. Yeah, tried that and the "body" param doesn't even feature in the POST params sent when you click the "try it out!" button. So not only is the "data" param being wrongly named it is also not being sent in the POST form data.

atomless avatar Jan 18 '16 13:01 atomless

I have the same issue. Did someone fixed it?

abscondite avatar Mar 30 '16 08:03 abscondite

I'm not sure, if it is relevant to swagger-1.2, but in 2.0 for file uploads the param_type must be formData, the type must be file and consumes must be either multipart/form-data or application/x-www-form-urlencoded, maybe setting this would fix it …

LeFnord avatar Mar 30 '16 08:03 LeFnord

It works. Thanks.

abscondite avatar Mar 30 '16 10:03 abscondite