Skip to content
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

Error when response content type is application/pdf #2054

Open
elev8studio opened this issue May 4, 2022 · 0 comments
Open

Error when response content type is application/pdf #2054

elev8studio opened this issue May 4, 2022 · 0 comments

Comments

@elev8studio
Copy link

Context

I am trying to document a PDF content type response in an openapi spec, and mock the response by running prism mock path/to/file.

Current Behavior

When I attempt the process described above, I get the error: Request terminated with error: Error: Cannot find serializer for application/pdf.

An example of the spec (that follows the latest syntax and best practice) that causes the problem:

responses:
  200:
    description: OK
    content:
      application/pdf:
        schema:
          type: string
          format: binary
        examples:
          default:
            summary: A sample report
            externalValue: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"

Expected Behavior

I've never seen it working, so I can't really describe what I expect to happen, other than I expect it to work without an error, and I expect to be able to download the PDF file sent in the response when testing the mock server in a tool such as Stoplight or Redocly.

Possible Workaround/Solution

Just providing the URL of the example PDF document as a string instead of using the externalValue property removes the error from the Prism CLI output, however when attempting to actually download the file, it is corrupted or fails to open. But it's arguabaly a better experience than an outright error, albeit still not a solution.

responses:
  200:
    description: OK
    content:
      application/pdf:
        schema:
          type: string
          format: binary
        examples: 
          - "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants