Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Swashbuckle.AspNetCore at build time

Is there any built-in way with Swashbuckle for ASP.NET Core to generate the swagger.json file at build or compile time (i.e. not with dotnet run)?

I'm starting down a path of microservices and I thought it would be nice to generate the swagger.json file at build time to allow other services to generate client APIs.

like image 402
Daniel A. White Avatar asked Nov 07 '22 14:11

Daniel A. White


1 Answers

You can use the Swashbuckle.AspNetCore.Cli to do this.

The CLI is versioned alongside the main package Swashbuckle.AspNetCore, so despite at the time of writing the readme saying use version 2.1.0-beta1, use the version that matches your use of Swashbuckle.AspNetCore.

like image 157
Simon Ness Avatar answered Nov 26 '22 01:11

Simon Ness