Search code examples
asp.net-coreswagger

How can I specify the default Media Type for the Swagger in ASP.NET Core 3.1?


How can I specify the default Media Type for the Swagger in ASP.NET Core 3.1?

E.g. I have three choices of the Media Type. And I want the default to be application/json, and not the text/plain. How can I do that?

enter image description here

enter image description here


Solution

  • Add the attribute to your api controller:

     [Produces("application/json")]