Reputation: 169
I'm creating swagger document for ASP.net API. I want to show in swagger that there is no response (other than status code) for any given status code. I have following attributes on my method:
This gives me following result in swagger:
As you can see status codes 200 and 500 does not have response type and this is what I want. But 401 has unnecessary response type. I want to get rid of it. The same is true for all other status codes (except 200 and 500). I've tried adding EmptyResult but this still produces empty brackets as a response:
Do you maybe know how I can configure this? I'm using Swashbuckle.
Upvotes: 0
Views: 696
Reputation: 6172
In the newer versions of ASP.NET CORE errors will produce an instance of ProblemDetails. You can disable it in ur Startup
using the following code:
services
.AddControllers() //or addMvc() for older projects
//below the important part to add
.ConfigureApiBehaviorOptions(options =>
{
options.SuppressMapClientErrors = true;
});
Upvotes: 2