Monday, April 18, 2016

Swagger 'GET' request always returns as text/html Accept type on response and NOT application/json

Leave a Comment

I have a swagger tag document using the Swagger UI that always returns text/html but it should return application/json. The POST requests and every other type returns application/json but this particular GET request does not. The service end point code is correct. And if I change the request to POST it does return as application/json. So it is just type GET within swagger which does not return the correct type. Any thoughts how to correct the call within the UI to use the application/json?

This is swagger version 2.1.4 that was downloaded recently from the swagger site.

 "/bankName": {             "get": {                 "summary": "Bank Name Search",                 "description": "Bank Name Search, input routing number to return bank name",                             "consumes": [                         "application/json"             ],                     "produces": [                     "application/json"                 ],                                                  "parameters": [                         {                             "in": "query",                                                       "name": "routingNumber",                             "description": "Input Bank Routing Number",                             "required": true,                                "type": "string",                                                    }                 ],                 "responses": {                     "200": {                         "description": "An array",                         "schema": {                             "type": "object",                             "properties": {                                 "errorInfo": {                                      "$ref": "#/definitions/ErrorInfo"                                                    },                                 "bankName": {                                     "type": "string",                                                                    }                             }                         }                                             },                     "400": {                             "description": "Invalid Request Input supplied"                                              },                                       "500": {                             "description": "General Unexpected Error"                     }                                        }             }         }   

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment