---
title: "Swagger Replacement in ASP.NET 9"
description: "You might have heard that Swagger is removed in the templates of ASP.NET 9. So this blog post will show you alternatives."
updated: 2024-09-23
tags: ["ASP.NET", ".NET 9"]
canonical: "https://steven-giesel.com/blogPost/777776a2-a13c-46bb-bf6b-89316d88508c/swagger-replacement-in-aspnet-9"
---

# Swagger Replacement in ASP.NET 9

You might have heard that Swagger is removed in the templates of ASP.NET 9. So this blog post will show you alternatives.

## Swagger removed
Swagger is a graphical tool that sits on top of the Open API which gives a graphical interface to interact and test your API. [The team announced that they removed Swagger from the templates in ASP.NET 9](https://github.com/dotnet/aspnetcore/issues/54599). Mainly because the team wants to leverage their own implementation and don't want to depend on Swashbuckle, which, according to the thread, is not longer maintained.

If you spin up a new project, you will "only" find this:

```csharp
builder.Services.AddOpenApi();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
}
```

`AddOpenApi` and `MapOpenApi` come from `Microsoft.AspNetCore.OpenApi` which is now included by default. And with this, you can generate the Open API specification! If you spin up you app and go to `https://localhost:<port>/openapi/v1.json` you have the spec!
But the interactivity is gone. So here are some options.

## Just install Swashbuckle again!
You can just install Swashbuckle again. It's still maintained and works perfectly. Just install the package and add the following code to your `Program.cs`:

```xml
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
```

And there we go! Swagger is back! The advantage of Swagger is, that it's really customizable and many folks need this degree of customization.

## NSwag
Another option is [NSwag](https://github.com/RicoSuter/NSwag). Also NSwag is capable of serving the Swagger UI. And similiar to Swashbuckle, you can also automatically create TypeScript types, ....

## Scalar
A relatively new one is: [Scalar](https://github.com/scalar/scalar). They have plenty of integration and of course also for .NET. I do like the appeal of their generated website. A quick onboarding guide is available [here](https://github.com/scalar/scalar/blob/main/packages/scalar.aspnetcore/README.md). But the very basic bit is:

Add the package:

```no-class
dotnet add package Scalar.AspNetCore
```

And add the following code to your `Program.cs`:

```diff
builder.Services.AddOpenApi();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
+    app.MapScalarApiReference();
}
```

Done! And this is how it looks:
![image](https://linkdotnetblog.azureedge.net/blog/20240923_OpenAPI/scalar.webp)