问题
I'm getting an error 500 back from Swashbuckle/Swagger, and contrary to the best related answer I could find, I'm not seeing any additional information in the error response.
I manually tracked down the problem endpoints by trial-and-error commenting out controllers and actions until I isolated the bad ones, but this is slow and doesn't tell me why certain endpoints have a problem. What can I do to get meaningful debug information for the Swagger/Swashbuckle errors?
I'm using Swashbuckle 5.6.0 and Swashbuckle.Core 5.6.0 in an ASP.Net 4.6.2 WebApi app. The only configuration is in a SwaggerConfig.cs file, seen below..
public class SwaggerConfig
{
public static void Register()
{
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "My.Namespace.Here.WebApi");
})
.EnableSwaggerUi(c =>
{
});
}
}
The swagger/docs/v1
returns a 500 response with the following:
回答1:
The problem is your URL
request .change HTTPS
to HTTP
.
http://localhost:xxxx/...
You can NOT simulate HTTPS locally because SSL certificate
doesn't exist in your local machine.
回答2:
Usually, I use Chrome Dev Tools to debug this kind of error. Also, you can get more information on Event Viewer if you are using Windows OS. Another option is checking the stacktrace from API's Swagger documentation site. For example api.domain.com/help/index or yourApiUrl/swagger/v1/swagger.json.
I've found a link could be helpful too: https://github.com/domaindrivendev/Swashbuckle/issues/969
Hope it helps.
来源:https://stackoverflow.com/questions/58956472/how-to-debug-error-500-in-swashbuckle-5-for-asp-net