【问题标题】:Response with headers swagger-ui带有标题的响应 swagger-ui
【发布时间】:2016-02-17 10:20:47
【问题描述】:

我正在使用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
     }

【问题讨论】:

标签: swagger swagger-ui swagger-2.0


【解决方案1】:

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

以下 yaml 对我来说可以正常工作,您的也应该可以正常工作。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-28
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多