Minimal API extensions for MinimalCleanArch.
- Current stable: 0.1.19-preview (net9.0, net10.0).
- bootstrap a Minimal API host with a consistent pipeline instead of wiring validation, errors, OpenAPI/Scalar, rate limiting, Serilog, and related concerns by hand
- keep HTTP-specific concerns out of your domain and infrastructure packages
- standardize API behavior across generated and hand-built MCA applications
- use it in the API/host project when you want the MCA HTTP pipeline and service-registration defaults over ASP.NET Core Minimal APIs
- choose it when your app exposes Minimal API endpoints and you want structured error mapping and endpoint conventions
- skip it in non-HTTP projects or when you intentionally want to assemble the host without MCA API helpers
- Depends on:
MinimalCleanArch - Typically referenced by: API/host projects
- Used by:
MinimalCleanArch.Validationfor validation integration - Do not reference from: domain projects; infrastructure projects should not need it except in very host-specific composition code
- Validation: request/body validation helpers (e.g.,
WithValidation<T>()). - Error handling: standard error pipeline middleware helpers, including structured
DomainException/Errormapping to RFC 7807. - Result mapping:
Result/ErrortoIResulthelpers for expected API outcomes (MatchHttp,ToProblem). - OpenAPI helpers: standard response definitions and filters.
- Rate limiting: global and named endpoint policies with consistent
429responses. - Misc: path parameter validation, minimal API conveniences.
dotnet add package MinimalCleanArch.Extensions --version 0.1.19-previewRecommended API bootstrap:
builder.Services.AddMinimalCleanArchApi(options =>
{
options.AddValidatorsFromAssemblyContaining<CreateTodoCommandValidator>();
options.EnableRateLimiting = true;
});Equivalent explicit registration:
builder.Services.AddMinimalCleanArchExtensions();
builder.Services.AddValidationFromAssemblyContaining<CreateTodoCommandValidator>();
builder.Services.AddMinimalCleanArchRateLimiting();Middleware:
app.UseMinimalCleanArchApiDefaults(options =>
{
options.UseRateLimiting = true;
});AddMinimalCleanArchApi(...) is the preferred entry point when you want a single bootstrap method. Use the explicit registrations when you need tighter control over the service graph.
Execution-context claim mapping can be customized without replacing IExecutionContext:
builder.Services.Configure<ExecutionContextOptions>(options =>
{
options.TenantIdClaimTypes.Clear();
options.TenantIdClaimTypes.Add("business_id");
});