0Pricing
C# Academy · Lesson

OpenAPI, Versioning & Deployment

Generate Swagger/OpenAPI docs, version APIs, and deploy a Minimal API to Azure App Service or containers.

OpenAPI in Minimal APIs

OpenAPI (formerly Swagger) generates interactive API documentation. In .NET 9, AddOpenApi() is built-in. For earlier versions, use Swashbuckle.AspNetCore.

Adding Swagger with Swashbuckle

Install Swashbuckle, configure it in services, and add the middleware to serve the spec and Swagger UI.

// dotnet add package Swashbuckle.AspNetCore

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(opt =>
    opt.SwaggerDoc("v1", new() { Title = "Products API", Version = "v1" }));

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

All lessons in this course

  1. Creating Your First Minimal API
  2. Route Groups, Parameters & Validation
  3. Middleware & Filters in Minimal APIs
  4. OpenAPI, Versioning & Deployment
← Back to C# Academy