-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Image response always uses file serving #1652
Comments
Something like this will probably fix this issue: This change is just a hacky example. It will need some work to integrate correctly. |
@dgreenbean Hi, |
I wrote that hack a while ago. Swagger-ui has probably been updated since. Specifically, this hack deals with requests sent through jQuery, not superagent. If your requests are going through superagent, they will need a similar hack. Also, my example assumes the response type is "file" in the Swagger spec. I have since found that using the Accept header of the request is probably more reliable. With this issue, my hope is to spark the discussion around what needs to be done for swagger-ui to actually support image, PDF and binary file outputs. While I primarily care about POST requests, the double-retrieve of GET requests is a little annoying. |
It'd be trivial to update swagger-ui to require JQuery when downloading an image. |
There's nothing inherently wrong with superagent. Really, both modes 2016-01-21 18:27 GMT-05:00 Tony Tam notifications@github.com:
|
I agree, but jquery does have some advantages for the UI stuff. We use it for file uploads in the ui |
Hi, As you said, there is this double GET method to retrieve a file.. It's a bit annoying, but it works.. The real problem is with a POST method as it's doing a GET method after the POST method on the POST endpoint.. Therefore, you always get a 405 code.. @fehguy @dgreenbean : Do you think there's a simple hack to get rid of this problem?? Sadly, I'm not really good with JavaScript and I can't find a solution to this problem.. Thanks for your answer.. |
This should not be an issue in the new UI. |
I have a POST request with accept = "image/jpeg" sent to the server on the path "/action"
The server processed the request and responded with Content-Type: image/jpeg and the data of the image.
The swagger-ui, as it seems, tries to show the image from "/action" via a new file serving (GET request) instead of the image of the data, which means that it thinks that the server supports file serving that way on this path.
It is important to mention the the path "/action" also supports a GET request for other purpose.
So to conclude this issue, the POST request returns the image data, which the swagger-ui won't even try to use.
The text was updated successfully, but these errors were encountered: