How to Install Swagger for .Net 2.2 Web API?

I had a “WTHek” time installing Swagger, the documentation tool.


So here is how to install Swagger in the right way.

Create a new Web API project.

Create a new Web API project in .Net Core 2.2

Ensure it is compiling fine.

Run Package Manager

Go to your Web API project & Run Package Manager command

Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4

Install-Package Microsoft.OpenApi.Models

Add Code to ConfigureServices() method

Towards the last.

services.AddSwaggerGen(c =>
c.SwaggerDoc(“v1”, new OpenApiInfo { Title = “My API”, Version = “v1” });

// Resolve namespace for OpenApiInfo

Add Code to Configure() method


app.UseSwaggerUI(c =>

c.SwaggerEndpoint(“/swagger/v1/swagger.json”, “API V1”);



Run the Application


You should be able to access the Swagger documentation as below:


More Debugging

If you missed any [HttpGet] attributes also swagger will give above “swagger.json” error.

Open the Output window to view which Controller method is causing trouble.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s