swagger-ui version 2.2.8
When an API returns a single string as a response it is shown as no content with response code 0 in Swagger-UI. (However, if the string consists only of digits, it seems to display the correct response and response code.
Swagger.json:
{
"swagger": "2.0",
"info": {
"title": "TestAPI",
"version": "1.0"
},
"host": "localhost:5000",
"basePath": "",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/test/string": {
"get": {
"tags": [
"TestAPI"
],
"operationId": "TestAPI_GetString",
"parameters": [],
"responses": {
"200": {
"description": "",
"schema": {
"type": "string"
},
"x-nullable": true
}
}
}
}
},
"definitions": {},
"responses": {},
"securityDefinitions": {}
}
Http response:
HTTP/1.1 200 OK
Date: Tue, 20 Dec 2016 09:30:59 GMT
Content-Type: application/json; charset=utf-8
Server: Kestrel
Content-Length: 5
Hello
Swagger UI Displays Response body as no content and Response Code as 0.
If you're saying that your server produces json:
"produces": [
"application/json"
]
But you return non-json, you're going to get an error. Consider returning the type that the server claims to produce.
Most helpful comment
If you're saying that your server produces json:
But you return non-json, you're going to get an error. Consider returning the type that the server claims to produce.