我正在使用ASP.net Core WebAPI并生成我正在使用Swagger的API文档 . Swagger成功生成了丰富多彩的文档 . 但是当我尝试执行api方法时 . 总是得到Swagger的轰鸣声错误 .
{“错误”:“服务器无响应”}
Api Method
[Route("api/[controller]")]
[Produces("application/json")]
public sealed class AuthController : BaseApiController
{
[HttpGet]
[Route("GetByUser/{uid}/{pwd}")]
public IActionResult GetByUser(string uid, string pwd){....}
}
Note:
-
我总是通过Browser / Fiddler( without using Swagger )从上面的方法得到正确的api响应
-
我也在api端配置CORS . 但是从Swagger仍然没有得到适当的回应 .
Swagger AppSettings
"Swagger": {
"FileName": "ApiDoument.xml",
"host": "localhost:63687"
}
Swagger Response
Curl
X GET 'http://localhost:63687/api/Auth/GetByUser/test%40gmail.com/1234'
Request URL
http://localhost:63687/api/Auth/GetByUser/test%40gmail.com/1234
Response Body
没有内容
Response Code
0
Response Headers
{“错误”:“服务器无响应”}
1 回答
问题解决了,上面描述的错误是由于波纹管哈希值造成的 . Swagger无法返回此类值 .
Solution: