Syed Uzair Uddin
Syed Uzair Uddin

Reputation: 3648

Response with headers swagger-ui

I am using Swagger-ui version 2.1.4, i have hosted it locally and provided it my own Json file and API it opens the document fine but i want to add headers in the Response Messages but i did not get how to do it, i followed the swagger specification to do it, but unfortunately i am still unsuccessful. My sample code is here.

 "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
     }

Upvotes: 3

Views: 12960

Answers (1)

Animesh
Animesh

Reputation: 227

Quite late for a reply but I chanced upon this while looking for an example of a similar requirement. Your stuff should work, not sure why it doesn't work for you. If you provided the exact error, that would have helped.

The following yaml works fine for me and yours should work fine also.

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

Upvotes: 4

Related Questions