Configuring Swagger UI in ASP.NET Core Web API

Chathurangi Jayawardana
2 min readOct 8, 2021

In this article, you can learn how to integrate Swagger UI in ASP.NET Core Web API Application.

Step 1:

Create a ASP.NET Core Web API project in Visual studio 2019.

Step 2:

Install package Swashbuckle.AspNetCore latest version to the project.

Step 3:

Configure the Swagger middleware.

First, Do the following changes in ConfigureServices() method of the Startup.cs class.

Then enable the middleware for serving the generated JSON document and the Swagger UI in Configure() method of the Startup.cs class.

Step 4:

Create Model Class in the project.

Step 5:

Create an API Controller with action methods.

Step 6:

Run the Application. You can find Swagger UI at https://localhost<port>/swagger

We can see Customer controller and its action methods here. Click on action methods and get detailed information of them.

Click on action methods and get detailed information of them.

Also click Try it out button and try to do GET, POST, PUT, DELETE actions.

Let’s try GET method to retrieve the data using Id.

Thank You!

--

--

Chathurangi Jayawardana

Software Engineer | Technical Writer | University of Moratuwa, Sri Lanka.