Skip to content

EN FastEndpoints

Vinícius Campos edited this page Aug 22, 2026 · 1 revision

FastEndpoints

Português · Back to docs

Offside.FastEndpoint is the only Offside package that references FastEndpoints. Validation failures and Result failures both become the same OffsideProblem document.

dotnet add package Offside
dotnet add package Offside.AspNetCore
dotnet add package Offside.FastEndpoint

Targets: net8.0, net10.0. Directly depends on FastEndpoints 8.3.0. In the locked restored graph, FastEndpoints brings FluentValidation 12.1.1 transitively; this is the effective version even though Offside.FluentValidation declares 11.11.0 directly.

Startup

builder.Services.AddOffside(options => { /* catalogs */ });
builder.Services.AddOffsideAspNetCore();
builder.Services.AddFastEndpoints();

app.UseFastEndpoints(c => c.UseOffside());

UseOffside does four things:

  • Sets Errors.ResponseBuilder so FluentValidation failures serialize as OffsideProblem.
  • Sets Errors.ProducesMetadataType to typeof(OffsideProblem).
  • Sets Errors.ContentType to application/problem+json.
  • Registers Produces<OffsideProblem> for every Offside status (400, 401, 403, 404, 409, 410, 412, 422, 429, 500) on all endpoints.

FastEndpoints does not expose the previous Endpoints.Configurator to other assemblies. If you already have one, pass it in:

app.UseFastEndpoints(c => c.UseOffside(ep =>
{
    ep.AllowAnonymous();
}));

Do not assign c.Endpoints.Configurator after UseOffside — that replaces the Offside metadata.

Opt out

Health and other endpoints that should not advertise Offside error statuses:

public override void Configure()
{
    Get("/health");
    Definition.DontProduceOffside();
}

Sending a Result

public override Task HandleAsync(CancellationToken ct) =>
    orders.Get(id).SendOffsideAsync(HttpContext, ct);

Success is 204 for Result and 200 with the value for Result<T>. Failure is the usual Offside problem document.

The CancellationToken parameter is present to match FastEndpoints handler signatures, but SendOffsideAsync ignores it. Cancelling ct does not cancel the delegated ToHttpResult(...).ExecuteAsync(...) response write.

FluentValidation

Use .WithErrorCode("email.required") to set the catalog key (Error.Code). The screen identifier for those errors is VALIDATION. See FluentValidation.

Clone this wiki locally