Bye-Bye Swashbuckle, Hello OpenAPI: What’s New in ASP.NET Core 9?
Amit Rana ????
?? Fintech Visionary | .NET & Java Developer | Payment Systems Ninja | EMV & ISO8583 Pro | Cloud & DevOps Adventurer ???
?? Big Change in ASP.NET Core 9! ??
Swashbuckle is gone from the default template! ?? (Wait, what?!) Yep, no more built-in Swagger docs in .NET 9 because it’s not actively maintained anymore. But don’t panic ,things are actually getting better! ??
What’s the New Buzz?
The .NET team is like, "Why stick with the old when we’ve got something cooler?" ??♂? So, they’ve introduced native support for OpenAPI document generation in .NET 9. ?? Here’s how it goes down:
But How Do You Actually Use It?
No more 3rd-party tools, just a clean, native way to generate docs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi(); app.Run();
Swashbuckle Lovers, Don't Cry! ??
I know, I know... you got a soft spot for Swashbuckle. And yes, you can still add it manually, but why not upgrade? Enter Nswag, the shiny new kid on the block. ?
Why Switch to Nswag?
How to Add Nswag:
dotnet add package NSwag.AspNetCore
builder.Services.AddSwaggerDocument(); // Nswag swagger app.UseOpenApi(); app.UseSwaggerUi3(); // Slick Swagger UI app.Run();
So, whether you want a simple, native OpenAPI setup or you still love a good swagger-y interface with Nswag, .NET 9 has you covered. ??
Remember:
No more tears, just swagger—oh, wait—Nswag swagger! ??
#DotNetCore #ASPNetCore9 #OpenAPI #Swagger #Nswag #APIDocs #DevLife #CSharp #CodingFun