Athenex.Whimclean.Api.FastEndpoints
2.0.0
Prefix Reserved
dotnet add package Athenex.Whimclean.Api.FastEndpoints --version 2.0.0
NuGet\Install-Package Athenex.Whimclean.Api.FastEndpoints -Version 2.0.0
<PackageReference Include="Athenex.Whimclean.Api.FastEndpoints" Version="2.0.0" />
<PackageVersion Include="Athenex.Whimclean.Api.FastEndpoints" Version="2.0.0" />
<PackageReference Include="Athenex.Whimclean.Api.FastEndpoints" />
paket add Athenex.Whimclean.Api.FastEndpoints --version 2.0.0
#r "nuget: Athenex.Whimclean.Api.FastEndpoints, 2.0.0"
#:package Athenex.Whimclean.Api.FastEndpoints@2.0.0
#addin nuget:?package=Athenex.Whimclean.Api.FastEndpoints&version=2.0.0
#tool nuget:?package=Athenex.Whimclean.Api.FastEndpoints&version=2.0.0
Athenex.Whimclean.Api.FastEndpoints
FastEndpoints adapter for Athenex.Whimclean.Api.AspNetCore, the primary Whimclean API package. Install it in applications that write their endpoints with FastEndpoints.
The adapter owns only what is specific to FastEndpoints:
- FastEndpoints registration and endpoint discovery, including discovery of plain FluentValidation validators;
- the FastEndpoints OpenAPI document;
- rendering of FastEndpoints validation failures as the shared error body;
- whole-value binding of
ListQueryRequestfilters.
Everything else comes from the primary package and behaves identically in both styles: the error body and exception mappings, status-code responses, Result mapping, the ListQueryRequest contract and its validator, current-user resolution, health endpoints, rate limiting and validated options.
Contents
Installation
dotnet add package Athenex.Whimclean.Api.FastEndpoints
The package references Athenex.Whimclean.Api.AspNetCore, FastEndpoints and FastEndpoints.OpenApi.
Quick start
using Athenex.Whimclean.Api.FastEndpoints;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFastEndpointsApi();
var app = builder.Build();
app.UseAuthentication(); // when authentication is configured
app.UseAuthorization(); // when authorization is configured
app.UseFastEndpointsApi();
app.Run();
With this setup:
- every endpoint lives under
/api/v1; - validators are discovered and run before the endpoint, and a failure answers 400
Validation.Failed; - every failure, from a thrown exception to an empty 404, answers with the shared error body described in Error responses;
- repeated
filtersquery values of aListQueryRequestare bound whole.
Registration reference
| Call | Applies to | What it does |
|---|---|---|
AddFastEndpointsApi(configureOpenApi) |
IServiceCollection |
Registers FastEndpoints with IncludeAbstractValidators enabled, the shared error handling from AddApiErrorHandling, and the FastEndpoints OpenAPI document. The optional delegate customizes DocumentOptions. |
AddFastEndpointsApi(configureOpenApi, configureDiscovery) |
IServiceCollection |
Same, with a hook that adjusts EndpointDiscoveryOptions after the adapter's settings are applied. |
UseFastEndpointsApi(routePrefix, configure) |
IApplicationBuilder |
UseApiErrorHandling plus UseFastEndpoints with the route prefix (default api/v1), the validation response builder and the filter binding. The optional delegate adjusts the FastEndpoints Config afterwards. |
Customizing the pipeline:
app.UseFastEndpointsApi(
routePrefix: "api/v2",
configure: options =>
{
options.Security.PermissionsClaimType = "permission";
});
OpenAPI
Configure the FastEndpoints document during registration:
builder.Services.AddFastEndpointsApi(document =>
{
document.Title = "Orders API";
});
Validation
Discovery
FastEndpoints pairs each request DTO with its validator at startup. The adapter enables IncludeAbstractValidators, so a validator may derive from FastEndpoints' Validator<TRequest> or directly from FluentValidation's AbstractValidator<TRequest>. This is what allows validators derived from the primary package's ListQueryRequestValidator<TRequest> to be discovered.
Because every AbstractValidator<T> descendant in the scanned assemblies is discovered, limit the scan when an assembly contains validators that are not request validators:
builder.Services.AddFastEndpointsApi(
configureOpenApi: null,
configureDiscovery: discovery => discovery.Assemblies = [typeof(Program).Assembly]);
A validator that derives from AbstractValidator<TRequest> cannot use FastEndpoints' Resolve<T>(); inject dependencies through the constructor instead.
Validation response
Failures are rendered through the primary package's ValidationHttpMapper, so the body matches a Minimal API exactly:
{
"code": "Validation.Failed",
"description": "One or more validation errors occurred.",
"errors": [
{ "code": "NotEmptyValidator", "description": "'Customer Id' must not be empty.", "field": "customerId" }
]
}
List endpoints
Derive the request from the primary package's ListQueryRequest and the validator from ListQueryRequestValidator<TRequest>. FastEndpoints binds the request from the query string, discovers the validator and runs it before the endpoint:
using Athenex.Whimclean.Api.AspNetCore.Queries;
using Athenex.Whimclean.Application.Pagination;
using Athenex.Whimclean.Application.Queries;
using FastEndpoints;
public sealed class ListTenantsRequest : ListQueryRequest;
public sealed class ListTenantsRequestValidator : ListQueryRequestValidator<ListTenantsRequest>
{
public ListTenantsRequestValidator()
{
AllowSortFields("slug", "name", "status");
AllowEnumFilterField<TenantStatus>("status");
AllowFilterField("createdAt", FilterOperator.GreaterThanOrEqual, FilterOperator.LessThan);
}
}
public sealed class ListTenantsEndpoint(ITenantQueries queries)
: Endpoint<ListTenantsRequest, OffsetPagedResult<TenantResponse>>
{
public override void Configure() => Get("tenants");
public override async Task HandleAsync(ListTenantsRequest request, CancellationToken ct) =>
await Send.OkAsync(await queries.ListAsync(request.ToListQueryOptions(), ct), ct);
}
The query-string parameters, validation rules and allow-list methods are documented in the primary package's List endpoints section.
UseFastEndpointsApi registers ListQueryBinding.KeepListQueryFiltersWhole, which binds each repeated filters value as-is so that a comma-separated in value (status:in:draft,published) stays in one filter. Call it yourself only when configuring UseFastEndpoints directly.
Error responses
Every failure response uses the primary package's body:
{
"code": "Order.NotFound",
"description": "The order was not found.",
"errors": null
}
| Condition | HTTP | Code |
|---|---|---|
CurrentUserRequiredException |
401 | Authentication.CurrentUserRequired |
PersistenceConcurrencyException |
409 | Persistence.ConcurrentUpdate |
| FastEndpoints validation failure | 400 | Validation.Failed |
| Response ended with 400 and no body | 400 | Request.Invalid |
| Response ended with 401 and no body | 401 | Authentication.Unauthorized |
| Response ended with 403 and no body | 403 | Authorization.Forbidden |
| Response ended with 404 and no body | 404 | Resource.NotFound |
| Any other exception | 500 | Server.UnexpectedError |
Unexpected exception details are logged and never returned to the client.
Returning a domain error from an endpoint
using Athenex.Whimclean.Api.AspNetCore.Errors;
var result = await handler.HandleAsync(request, ct);
if (result.IsFailure)
{
await Send.ResultAsync(result.Error.ToHttpResult());
return;
}
ErrorType maps to status codes as in the primary package: Validation 400, Unauthorized 401, Forbidden 403, NotFound 404, Conflict 409, Failure 500.
Adding an exception mapping
Register an IApiExceptionMapper; see Adding an exception mapping in the primary package. Mappers are probed in registration order and the first match wins.
Repository and architecture guide: https://github.com/athene-x/Whimclean
| 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
- Athenex.Whimclean.Api.AspNetCore (>= 2.0.0)
- FastEndpoints (>= 8.2.0)
- FastEndpoints.OpenApi (>= 8.2.0)
- Microsoft.AspNetCore.OpenApi (>= 10.0.10)
- Microsoft.OpenApi (>= 2.7.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 108 | 11/17/2026 |
Thin adapter over Athenex.Whimclean.Api.AspNetCore: discovers validators derived from its ListQueryRequestValidator, renders validation failures through its shared mapper, applies whole-value binding of ListQueryRequest filters in UseFastEndpointsApi, and offers an AddFastEndpointsApi overload with an endpoint discovery hook.