Handling file uploads from swagger-ui

74 views
Skip to first unread message

Clay Himmelberger

unread,
Mar 11, 2014, 9:18:35 AM3/11/14
to res...@googlegroups.com
I am asking this question on the swagger-ui board as well. Wondering if anyone has run into this when mixing restify, NodeJS and swagger-ui

In NodeJS, I am running restify (2.6.3) to handle HTTP calls. Using a package to define a swagger documentation (JSON files), and can use the swagger-ui (2.0.13) to test all my REST resources. I am running into problems when defining a resource that accepts a file upload and sending that file from the swagger-ui page.

sending my file using cURL works fine: curl -F file=@list.csv localhost:3001/plan/1/batch -i

And the file is handled by restify, appearing in "req.files.file" inside the handling function.

When I send the file via swagger-ui, my app never reaches the POST handling function in restify (using node-inspector for debugging). swagger-ui reports Response Code 200, no response body, and "{
  "Content-Type": " application/json\r\n"
}"

Which looks a little odd. 

I have tried sending the file as a form parameter or a body parameter. Other form or body parameters (json, strings, numbers, etc) work just fine, but when the file is included in the spec, the call never fully completes.

I plan to proceed with a working swagger-ui here, but wondered if it could be rectified? Is there any information I could provide to you, or things I should try, to track down the root cause of this? Things have been working great so far, and I'd like this piece to work as well for a completely documented app : )

Thanks,
Clay
Reply all
Reply to author
Forward
0 new messages