This is basically the same question as How do I set or remove the Default Response Content Type Using SwashBuckle, but for .NET Core 3.0
By default in .NET Core 3.0, you configure a web api with services.AddControllers()
and then you configure swagger with swashbuckle with services.AddSwaggerGen()
+ app.UseSwagger()
That is working fine, however the swagger.json contains multiple response content types for every operation (text/plain + application/json + text/json)
I know I can restrict these response content types by adding [Produces]
and [Consumes]
to my operations, but I'd like to avoid that for each and every operation (i.e I want to do that globally)
Please note that I preferably want to use System.Text.Json but if you have a solution that works only with Newtonsoft.JSON then it's better than nothing ;)