version v2.2.8 of Swagger-UI
I am getting "No response from server" only when I test with incorrect parameters and Express's error handler gets called.
The browser returns results as expected. Also, in the Chrome network tab, I can see the response code as 400 (which is correct). However, the UI shows response code 0.
Response Body: no content
Response Code: 0
Response Headers
{
"error": "no response from server"
}
However, the successful calls are displayed without any issues.
Maybe this answer 2584 can help you.
Hi,
I have the exact same same issue. For valid requests the response body is shown, but when there is an error it shows the same message as peacemakr showed above.
The responses are valid json, for example:
{
"message": "Forbidden"
}
The response-headers look like this:
Content-Length: 24
Content-Type: application/json
Date: Thu, 23 Feb 2017 12:29:13 GMT
Via: 1.1 ...
X-Amz-Cf-Id: ...
X-Cache: Error from cloudfront
X-Firefox-Spdy: h2
x-amzn-errortype: ForbiddenException
x-amzn-requestid: ...
Does anybody know how to fix this?
@ben31414 If the domain of your API in your swagger.json does not match that which swagger ui is hosted on, the response might be lacking CORS headers? The api could be only adding them to the successful responses?
"error": "no response from server" is the error you get when the request is blocked by the CORS policy.
@okneloper thanks a lot!
That was a very good and helpfull hint!
For other people with the same problem, using the AWS API-Gateway: it seems that you have to add the header "access-control-allow-origin" to the method response of every error message and set it's value in the integration response to "'*'".
This should no longer be an issue with 3.X.
@webron,
I see springfox swagger ui has the latest version as 2.8. may i please know 3.x version of what you are referring too ?
@kumarz Springfox is using Swagger-UI version 3.9.1 that is recent but not latest:
https://github.com/springfox/springfox/blob/master/springfox-swagger-ui/build.gradle
...and yes 3.9.1 is part of the 3.x family
The issue described here should not be happening on Springfox 2.8.0
Most helpful comment
@ben31414 If the domain of your API in your swagger.json does not match that which swagger ui is hosted on, the response might be lacking CORS headers? The api could be only adding them to the successful responses?
"error": "no response from server" is the error you get when the request is blocked by the CORS policy.