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"
}
}
}
}
Accept:application/json
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:9086
Origin:http://localhost:9086
Pragma:no-cache
Referer:http://localhost:9086/swagger/index.html
Here is the Java code Spring Restful definition:
@RequestMapping(value="bankName",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
The major Swagger tools include: Swagger Editor – browser-based editor where you can write OpenAPI definitions. Swagger UI – renders OpenAPI definitions as interactive documentation. Swagger Codegen – generates server stubs and client libraries from an OpenAPI definition.
Have you tried this?
"/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",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"errorInfo": {
"$ref": "#/definitions/ErrorInfo"
},
"bankName": {
"type": "string",
}
}
}
}
}
},
"400": {
"description": "Invalid Request Input supplied"
},
"500": {
"description": "General Unexpected Error"
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With