DKNet.AspCore.Extensions
10.1.8
See the version list below for details.
dotnet add package DKNet.AspCore.Extensions --version 10.1.8
NuGet\Install-Package DKNet.AspCore.Extensions -Version 10.1.8
<PackageReference Include="DKNet.AspCore.Extensions" Version="10.1.8" />
<PackageVersion Include="DKNet.AspCore.Extensions" Version="10.1.8" />
<PackageReference Include="DKNet.AspCore.Extensions" />
paket add DKNet.AspCore.Extensions --version 10.1.8
#r "nuget: DKNet.AspCore.Extensions, 10.1.8"
#:package DKNet.AspCore.Extensions@10.1.8
#addin nuget:?package=DKNet.AspCore.Extensions&version=10.1.8
#tool nuget:?package=DKNet.AspCore.Extensions&version=10.1.8
DKNet.AspCore.Extensions
The minimal-API glue for DKNet-based ASP.NET Core web APIs: claim-backed request binding,
versioned endpoint-group discovery, one-line SlimMessageBus mapping helpers, a shared paging
envelope, and FluentResults-to-IResult/ProblemDetails conversion.
Installation
dotnet add package DKNet.AspCore.Extensions
Features
- Contextual request binding —
[FromClaim](and any customIContextualSource) populates a request property from the authenticated caller before validation and before the handler runs, so it can never be forged through the request body or querystring; automatically excluded from the published OpenAPI description. - Endpoint group discovery — implement
IEndpointConfigper feature area and letUseEndpointConfigs()discover, version, tag, and authorize every group across your assemblies. - Fluent minimal-API mappers —
MapPost/MapPut/MapPatch/MapDelete/MapGet/MapGetPagewire a verb straight onto a SlimMessageBus fluent command/query, plus genericMapGetById/MapGetListbacked byDKNet.EfCore.Specifications. PagedResponse<T>— a shared paging envelope (PageNumber,PageSize,PageCount,TotalItemCount,Items,HasNextPage,HasPreviousPage) used by every paged endpoint.- Result/ProblemDetails conversion —
Response()/Response<T>()turn aFluentResultsoutcome into the right minimal-APIIResult;ToProblemDetails()does the same for aModelStateDictionary.
Quick Start
Register the pieces you need and let UseEndpointConfigs do the mapping:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
builder.Services.AddApiVersioning();
builder.Services.AddContextualRequestPopulation(); // powers [FromClaim] and friends
var app = builder.Build();
app.UseEndpointConfigs(); // discovers every IEndpointConfig across the loaded assemblies
app.Run();
using System.Security.Claims;
using DKNet.AspCore.Extensions;
using DKNet.AspCore.Extensions.ModelBinding;
using DKNet.SlimBus.Extensions;
public sealed record CreateProductCommand : Fluents.Requests.IWitResponse<ProductModel>
{
public string Name { get; init; } = string.Empty;
[FromClaim(ClaimTypes.NameIdentifier)]
public string? CreatedBy { get; set; } // always resolved from the caller's claim, never from the body
}
public sealed class ProductsEndpointConfig : IEndpointConfig
{
public string GroupEndpoint => "/products";
public void Map(RouteGroupBuilder group) =>
group.MapPost<CreateProductCommand, ProductModel>("/");
}
POST /v1/products now dispatches CreateProductCommand through IMessageBus, resolves
CreatedBy from the caller's claim before the handler runs, and returns 201 Created (the mapper
infers "Created" from the command's type name) with a FluentResults-derived ProblemDetails body
on failure.
Migration — namespace changes in this release
Root types were grouped into concern folders; the namespace of each moved type now ends
with its folder name. This is an import-only source break: no type was renamed, removed,
resignatured, or had its behaviour changed — update the using line and you're done.
| Type | Old namespace | New namespace |
|---|---|---|
IContextualSource, FromClaimAttribute, ContextualValueResolver, ContextualRequestPopulation (+ its internal helpers), ContextualSourceOpenApiTransformers |
DKNet.AspCore.Extensions |
DKNet.AspCore.Extensions.ModelBinding |
EndpointConfigExtensions (incl. EndpointRegistrationOptions, UseEndpointConfigs), FluentEndpointMapperExtensions |
DKNet.AspCore.Extensions |
DKNet.AspCore.Extensions.Endpoints |
PagedResponse<T>, ProblemDetailsExtensions, ResultResponseExtensions |
DKNet.AspCore.Extensions |
DKNet.AspCore.Extensions.Responses |
IEndpointConfig — the package's entry surface — stays at DKNet.AspCore.Extensions.
Full Documentation
See the full feature guide
for contextual-source resolvers, EndpointRegistrationOptions, all fluent mappers, paging
details, and gotchas.
License
This project is licensed under the MIT License - see the LICENSE file for details.
About
Developed by Steven Hoang.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Asp.Versioning.Http (>= 10.2.2)
- DKNet.EfCore.Specifications (>= 10.1.8)
- DKNet.SlimBus.Extensions (>= 10.1.8)
- FluentResults (>= 4.0.0)
- Microsoft.AspNetCore.OpenApi (>= 10.0.11)
- SharpGrip.FluentValidation.AutoValidation.Endpoints (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.