-
Notifications
You must be signed in to change notification settings - Fork 3
How to add swagger
Nordes Ménard-Lamarre edited this page Oct 24, 2018
·
1 revision
-
dotnet add package Swashbuckle.AspNetCore- This will download and install all the deps.
- Open your
startup.csfile.
- Add in the
ConfigureServicesmethod
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});- Into the
Configureyou will have to add
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});Now you should be good to do a dotnet run and open the url https://localhost:5001/swagger/
More detailed guide can be found on the MSDN website and I recommend you to go and look.
© 2018 HoNoSoFt / Nordès