2015-08-24 39 views
14

我在需要返回pdf文件的Swagger REST API中有一个get call。没有清楚的示例/文档说明如何在不引起语法错误的情况下执行此操作。如何指定pdf在swagger中返回?

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

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

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

全部失败。这甚至有可能吗?

回答

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

在您给出的选项中,这是正确的选项。此外,请务必使用produces: [application/pdf]

如果它失败了,请确保使用最新版本的编辑器。最近解决了一个与file类型有关的错误。

相关问题