响应标头swagger-ui

时间:2016-02-17 10:20:48

标签: swagger swagger-ui swagger-2.0

我正在使用Swagger-ui version 2.1.4,我在本地托管它,并提供了我自己的Json文件和API,它打开文档很好,但我想在响应消息中添加标题,但我没有得到如何做到这一点,我按照swagger specification来做,但不幸的是我仍然没有成功。 我的示例代码在这里。

 "responses" : {
           "200" : {
              "description" : "SUCCESSFULLY_RETRIVED",
              "schema" : {
                 "$ref" : "#/definitions/Object"
              }
           },
           "500" : {
               "description" : "UNKNOWN_SERVER_ERROR",
               "headers": {
               "X-Rate-Limit-Limit": {
               "description": "The number of allowed requests in the current period",
               "type": "integer"
               }                    
           }

        },
        "deprecated" : false
     }

1 个答案:

答案 0 :(得分:3)

回复很晚,但我在寻找类似要求的例子时偶然发现了这个问题。你的东西应该工作,不知道为什么它不适合你。如果您提供了确切的错误,那将会有所帮助。

以下yaml适用于我,你的工作也应该正常。

    500:
      description: Customer creation error
      headers:
        Error-Id:
          description: the relevant 500 Error
          type: string