apigee-127 / swagger-tools

A Node.js and browser module that provides tooling around Swagger.
MIT License
701 stars 373 forks source link

File is corrupted if i download it when validateResponse is true #586

Open daemyn opened 6 years ago

daemyn commented 6 years ago

I made an api with an endpoint that returns/download a file (application/pdf for now) But when i download the file and open it it's corrupted, however when i disable validateResponse in swaggerValidator middleware the file will be downloaded perfectly ! it seems like this middleware is altering the response Is there a way to fix this?

lerit commented 5 years ago

same problem

HanOterLin commented 5 years ago

make sure the header sets: res.setHeader('Content-Length', file.size); res.setHeader('Content-Type', 'application/pdf'); res.setHeader('Content-Disposition', 'attachment; filename=file.pdf')

If it still not work, you can try to update your swagger-ui version to 3.0.0+