I use swagger-UI 2.1.3 for API documentation and in the backend, I use spring -webmvc.
I have one API that returns a PDF file, it works fine if I find the URL in the browser (it pops up, loading and the downloaded file works fine)
But the same api does not work in swagger ui, it gives me a download link after clicking "try out", and this link downloads the file, but this file shows me blank pages in pdf format (damaged pdf file).
Answer headers follow
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: public Expires: 0 Access-Control-Allow-Origin: * Content-Description: File Transfer Content-Transfer-Encoding: binary Transfer-Encoding: chunked Content-Disposition: attachment; filename="example.pdf" Access-Control-Expose-Headers: Content-Description,Content-Disposition,location Content-Type: application/pdf Content-Length: 268288 Date: Mon, 04 Jan 2016 12:18:16 GMT
Any solution around this?
Addition Information:
These questions seem similar - AngularJS: Show blob (.pdf) in angular app
There they say set responseType for arraybuffer in xhr, but I think swaggar will take care of this (maybe I need to set some configuration?)
spring-mvc swagger-ui
Vivek
source share