Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
     }
like image 816
Syed Uzair Uddin Avatar asked Oct 23 '25 03:10

Syed Uzair Uddin


1 Answers

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
like image 186
Animesh Avatar answered Oct 25 '25 22:10

Animesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!