-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue in downloading/viewing the PDF content with content type "application/pdf" and "application/octet-stream" in Swagger 3.0 #4250
Comments
You haven't specified which version of swagger-ui. Also, in this case, without a live server for us to test against, it would be difficult to reproduce. |
@balaji-tech87 your example works fine for me using Swagger UI 3.11.0 and PDFs on GitHub. The response section displays the "Download file" link. The issue is likely with your server. openapi: 3.0.0
info:
title: PDF test
version: 0.0.0
servers:
- url: https://raw.githubusercontent.com
paths:
/mozilla/pdf.js/master/examples/learning/helloworld.pdf:
get:
responses:
'200':
description: A PDF file
content:
application/pdf:
schema:
type: string
format: binary
application/octet-stream:
schema:
type: string
format: binary |
Hi @balaji-tech87! I ran @hkosova's example through a web proxy that modified GitHub's
Swagger-UI does not support inline viewing of PDFs, nor do I expect it to do so in the future. PDF rendering is not easy to do consistently in a web application, and even then it requires heavy libraries. Swagger-UI does allow for file downloading, as you know - however you'd need to either send Learn more about |
Hi Team, Suggestions: |
Thanks. Closing the ticket. I will raise new ticket, if any further clarification required. Thanks for your support. |
Demonstration API definition
Case 1:
responses:
'200':
description: "".
content:
application/pdf:
schema:
type: string
format: binary
Case 2:
responses:
'200':
description: "".
content:
application/octet-stream:
schema:
type: string
format: binary
Configuration (browser query string, constructor, config.yaml)
Case1:
curl -X GET "http://localhost:8080/rest/*****true" -H "accept: application/pdf"
Case2:
curl -X GET "http://localhost:8080/rest/*****true" -H "accept: application/octet-stream"
Expected Behavior
It should either display the PDF content in the browser or it should provide link to download the file.
And with the same curl command returns the download prompt for pdf file, while trying in postman tool.
Current Behavior
Case 1:
It throws Not acceptable error - 406.
Case 2:
It throws 200 - Unknown response type.
Possible Solution
Context
Writing an api to download the PDF content
The text was updated successfully, but these errors were encountered: