swagger-ui: Download link in response body does not work
I am having a problem similar to the ones described in #374 and #1196. I have a service which returns a pdf file as attachment with Content-Disposition header. This works when I call the endpoint from the browser - file is downloaded. On Swagger UI I get a download link after calling the service with response content type application/pdf, however that link downloads an empty pdf file:

My swagger.json is generated by Enunciate (version 2.3.0) and the relevant part looks like this:
"responses": {
"200": {
"schema": {
"description": "",
"$ref": "#/definitions/json_File"
}, ...
I tried adding "type": "file" to the schema, but it didn’t fix the problem. What could be going wrong here?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 33 (9 by maintainers)
@fehguy ok I will show my backend java code also the swagger UI responses i get JAVA (server side): I am returning file and this would be a image, mp3, vedio, pdf, text etc
On download this file, the file name is this as shown in the below image(which is not the actual file name) also the file gets corrupt.
Also when i hit my server URL directly on the browser I get the exact file . please text if need any thing else?