How to generate a swagger.json file on build in .NET core, .NET 5 and above

Wouter
3 min readFeb 5, 2021

Swagger is a powerful tool to create Web APIs in .NET Core (and .NET 5). When your API is online there is a swagger.json file that contains the entire definition of your API. But did you know that there is a way to generate this swagger.json file on build time?

What is a swagger file?

A swagger file (nowadays known as a OpenAPI specification file) is a JSON file that contains the entire definition of your API. All endpoints, input- and response types are…

--

--