Adding Swagger to my ASP.Net Core API

Continuing on the MyReverie solution building upon my last post on this My Reverie.

What I would now like to do is add some API documentation around the my API

The reason I am choosing swagger is simply that it is the largest framework of API developer tools for the OpenAPI specific which allows rapid documentation and testing my APIs with great ease.

For reference check out their website @

Let’s get started

First we want to add the Swashbuckle package from Nuget

So right click the Goals.API project

Click Manage Nuget Packages


Under Browse tab search for Swashbuckle.AspNetCore


Once found click install

Once installed we want to add the Swashbuckle namespace ‘Swashbuckle.AspNetCore.Swagger’ to our Startup class

In the ConfigureServices method add:

services.AddSwaggerGen(c =>


c.SwaggerDoc(“v1”, new Info { Title = “My Reverie”, Version = “v1” });



Next, In the Configure method

In the cope of the env.IsDevelopment() check, add


app.UseSwaggerUI(options =>


options.SwaggerEndpoint(“/swagger/v1/swagger.json”, “My Reverie V1”);



Lets run it to see what it looks like, you should see something like below


To try it out simple select the Get button

Click the Try it out button on top right

Then hit execute


We’ve just added swagger to the API to add a basic documentation and testing base in which to build upon.