How to specify that a pdf is returned in swagger?

Scottingham picture Scottingham · Aug 24, 2015 · Viewed 14.8k times · Source

I have a get call in my swagger REST API that needs to return a pdf file. There is no clear example / documentation on how to do this without causing a syntax error.

  responses:
    200:
      description: Returns PDF
      schema: [application/pdf]

and

  responses:
    200:
      description: Returns PDF
      schema: 
        type: file

and

  responses:
    200:
      description: Returns PDF
      schema:
        type:  [application/pdf]

all fail. Is this even possible?

Answer

Ron picture Ron · Aug 25, 2015
  responses:
    200:
      description: Returns PDF
      schema: 
        type: file

Out of the options you gave, that's the right option. Also, make sure to use produces: [application/pdf]

If it fails for you, make sure you use the latest version of the editor. There was a bug related to the file type that was recently resolved.