swagger-api / swagger-api/swagger-ui

Does not download with File name which is present in tag"filename"

Open
#7,577 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Versions:
Swagger-UI: 3.25.0
Swagger-Client: 3.10.9
Edge: 95.0
Chrome: 95.0

The same issue was encountered here https://github.com/swagger-api/swagger-ui/issues/1991 and it solved in https://github.com/swagger-api/swagger-ui/pull/1993 in swagger-ui version 2.2.1

However, I am still experiencing the same issue regarding the file name for the octet-stream media type.

Response Header:

content-type: application/pdf
content-disposition: attachment; filename = Category Sales and Profit Performance.pdf 

Code wise:

Response.ok().entity(data).type(MediaType.APPLICATION_OCTET_STREAM_VALUE)
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename = "+ documentName +".pdf")
                .build();

I have also tried with content-type: application/octet-stream instead of pdf but the same issue.

when I click on "download" from swagger, it is downloading with "application_pdf_pdf_blob_http___nameOftheHost_e64cc118-ce7c-4d7d-b795-288a4dc309c2.pdf" instead of "Category Sales and Profit Performance.pdf"

Note: I also tried with Swagger-UI: 3.52.5. The issue is still present.

I have download the source code and checked, that logic to fetch the name of the file from "fileName" is not present under Swagger-ui/dist/swagger-ui.js

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the download with Swagger-UI 3.52.5 using the supplied Content-Disposition and media-type examples. Inspect the source corresponding to Swagger-ui/dist/swagger-ui.js and the download handling path; done means the downloaded file uses the response's filename instead of the generated blob URL name.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.