Open HarshChakalasiya opened 2 months ago
Hi @HarshChakalasiya I fixed that error modifying my endpoint and the documentation of Swagger definition:
In the endpoint set a properties on res, for example:
res.set({
"Content-Type": "application/pdf",
"Content-Length": pdfBuffer.length, // If have the length of the PDF
"Access-Control-Expose-Headers": "Content-Disposition",
"Content-Disposition": "attachment; filename=nameFile.pdf",
});
After, modify the Swagger definition, for example:
'200':
description: PDF success.
content:
application/pdf:
schema:
type: string
format: binary
With that changes in the Swagger UI the Response Body show a Button to Download the pdf.
Q&A (please complete the following information)
Content & configuration
Swagger/OpenAPI definition:
Swagger-UI configuration options:
How can we help?
Hello,
I am hitting one api which gives zip file as response with Content-Disposition, Content-Type response headers. When I am trying to hit that api from postman, I will get the file response and I can download the zip file but in swagger, I am receiving the file response as text with
Unrecognized response type; displaying content as text.
this error and it is downloaded as text file when I am trying to download it.Here I pasted the json config file of that swagger route.
I am receiving following response headers values.
So can anyone help to figure it out.