Minimal APIs are not a stripped-down version of controllers. It is the same ASP.NET Core, minus a layer of classes that explains nothing in a small service. If your backend is a dozen endpoints and a database, the whole skeleton fits in one file, and a new person on the team reads it top to bottom.
Endpoints
The starting point is WebApplication, a route group and the Map* methods. Use TypedResults instead of IActionResult: the compiler then sees every possible response, and the OpenAPI generator gets their description for free.
using Microsoft.AspNetCore.Http.HttpResults;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<IItemStore, InMemoryItemStore>();
var app = builder.Build();
var items = app.MapGroup("/api/items").WithTags("items");
items.MapGet("/{id:guid}", Results<Ok<Item>, NotFound> (Guid id, IItemStore store) =>
store.Find(id) is { } item
? TypedResults.Ok(item)
: TypedResults.NotFound());
items.MapPost("/", (CreateItem request, IItemStore store) =>
{
var item = store.Add(request.Name, request.Quantity);
return TypedResults.Created($"/api/items/{item.Id}", item);
});
app.Run();
public record Item(Guid Id, string Name, int Quantity);
public record CreateItem(string Name, int Quantity);The Results<Ok<Item>, NotFound> type is an important detail: if you add a third path that returns something else, the code will not compile until you update the signature. The contract stays together with the code.
Validation
In .NET 10, Minimal APIs have built-in parameter validation. You turn it on with one line and describe the rules with DataAnnotations attributes on the request type.
using System.ComponentModel.DataAnnotations;
builder.Services.AddValidation();
public record CreateItem(
[Required, StringLength(80, MinimumLength = 3)] string Name,
[Range(1, 1000)] int Quantity);When the data is invalid, the endpoint answers with 400 and a description of the errors in the problem details format, and your handler does not run at all. Request types must be declared in regular .cs files. Attribute validation covers rules for single fields. Rules that need the database (a unique name) stay in code, or in the database as a constraint.
OpenAPI
The OpenAPI document is generated by the Microsoft.AspNetCore.OpenApi package. Registration is two lines, and the document is available at /openapi/v1.json.
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi();You add operation names and descriptions on the endpoints: .WithName("GetItem"), .WithSummary("Gets an item by its identifier"). A good operation name has a practical value, because client generators use it to name methods.
Options pattern
Keep settings from appsettings.json and environment variables in typed classes, and validate them at startup. Then a bad configuration brings the application down immediately, not on Friday evening at first use.
public class StorageOptions
{
public const string Section = "Storage";
[Required, MinLength(1)]
public string Bucket { get; set; } = "";
[Range(1, 100)]
public int MaxItems { get; set; } = 10;
}
builder.Services.AddOptions<StorageOptions>()
.BindConfiguration(StorageOptions.Section)
.ValidateDataAnnotations()
.ValidateOnStart();In a service you inject IOptions<StorageOptions> and read .Value. The environment variable Storage__MaxItems=20 overrides the value from the file, because a double underscore replaces the colon in the key name.
Health checks
An orchestrator needs two answers: is the process alive, and is it ready to take traffic. The first should not touch the database, the second should.
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Npgsql;
builder.Services.AddHealthChecks()
.AddCheck<DatabaseCheck>("database", tags: ["ready"]);
app.MapHealthChecks("/health/live", new() { Predicate = _ => false });
app.MapHealthChecks("/health/ready", new() { Predicate = c => c.Tags.Contains("ready") });
public class DatabaseCheck(NpgsqlDataSource dataSource) : IHealthCheck
{
public async Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
await using var command = dataSource.CreateCommand("select 1");
await command.ExecuteScalarAsync(cancellationToken);
return HealthCheckResult.Healthy();
}
catch (Exception ex)
{
return HealthCheckResult.Unhealthy("The database is not responding", ex);
}
}
}Predicate = _ => false turns off all checks, so /health/live answers as long as the process accepts requests. You register the NpgsqlDataSource with the Npgsql.DependencyInjection package.
Why LTS matters in a small team
.NET 10 is a long-term support (LTS) release. In practice it means that for roughly three years after release you get bug and security fixes without having to change the major version. For a large company that is a line in a policy. For a team of three it is a concrete saving: upgrading the framework is work nobody has in the plan, and releases without long support force it more often.
A rule that works: pick the LTS, pin a specific SDK version in global.json, and apply patch updates regularly, with a major version once every few years. Boring, but predictable. Check the exact end-of-support dates on the .NET support policy page before putting them in a schedule.
What is not here
There are no controllers, filters, routing attributes or base classes. When the service grows, you move endpoints into extension methods like MapItemEndpoints(this IEndpointRouteBuilder app) and still have the same readable flow. Nothing more is needed until a specific problem forces it.