Olve.MinimalApi 0.37.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Olve.MinimalApi --version 0.37.2
                    
NuGet\Install-Package Olve.MinimalApi -Version 0.37.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Olve.MinimalApi" Version="0.37.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Olve.MinimalApi" Version="0.37.2" />
                    
Directory.Packages.props
<PackageReference Include="Olve.MinimalApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Olve.MinimalApi --version 0.37.2
                    
#r "nuget: Olve.MinimalApi, 0.37.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Olve.MinimalApi@0.37.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Olve.MinimalApi&version=0.37.2
                    
Install as a Cake Addin
#tool nuget:?package=Olve.MinimalApi&version=0.37.2
                    
Install as a Cake Tool

Olve.MinimalApi

NuGet Docs

ASP.NET Core Minimal API extensions for Olve.Results. Maps Result and Result<T> to HTTP responses, adds endpoint validation filters, and provides JSON conversion for IPath.


Installation

dotnet add package Olve.MinimalApi

Overview

Type Description
ResultMappingExtensions Maps Result / Result<T> to 200 OK or 400 Bad Request responses.
ValidationApiExtensions Adds endpoint validation filters using IValidator<T>.
IHandler<TRequest> Handler interface returning Result.
IHandler<TRequest, TResponse> Handler interface returning Result<TResponse>.
PathJsonConverter JSON converter for IPath round-trip serialization.
ServiceExtensions Registers PathJsonConverter in JSON options.

Usage

Result mapping

Use WithResultMapping() on a RouteHandlerBuilder to automatically convert Result and Result<T> return values into HTTP responses:

app.MapGet("/users/{id}", (int id, UserHandler handler, CancellationToken ct)
        => handler.HandleAsync(new GetUser(id), ct))
    .WithResultMapping<UserDto>();
Return value HTTP response
Result success 200 OK (empty body)
Result<T> success 200 OK with T as body
Any failure 400 Bad Request with ResultProblem[] as body

The non-generic WithResultMapping() is used when the handler returns Result (no value):

app.MapDelete("/users/{id}", (int id, DeleteHandler handler, CancellationToken ct)
        => handler.RunAsync(new DeleteUser(id), ct))
    .WithResultMapping();

You can also convert results manually with the ToHttpResult() extension:

app.MapGet("/manual", () =>
{
    Result<string> result = Result.Success("hello");
    return result.ToHttpResult();
});

Validation

Use WithValidation<TRequest, TValidator>() on a RouteHandlerBuilder to validate requests before the handler runs. If validation fails, a 400 Bad Request with the validation problems is returned immediately:

app.MapPost("/users", (CreateUserRequest request, UserHandler handler, CancellationToken ct)
        => handler.HandleAsync(request, ct))
    .WithResultMapping<UserDto>()
    .WithValidation<CreateUserRequest, CreateUserValidator>();

The validator must implement IValidator<TRequest> from Olve.Validation. A new instance is created per endpoint by default, or you can pass an existing instance:

var validator = new CreateUserValidator();
app.MapPost("/users", ...)
    .WithValidation<CreateUserRequest, CreateUserValidator>(validator);

Handler interfaces

Two handler interfaces standardize the request/response pattern:

// For operations that return no value (e.g. delete, update)
public interface IHandler<in TRequest>
{
    Task<Result> RunAsync(TRequest request, CancellationToken cancellationToken);
}

// For operations that return a value (e.g. get, create)
public interface IHandler<in TRequest, TResponse>
{
    Task<Result<TResponse>> HandleAsync(TRequest request, CancellationToken cancellationToken);
}

Path JSON conversion

Register PathJsonConverter to enable JSON round-trip serialization of IPath values:

builder.Services.WithPathJsonConversion();

This adds the converter to the default JsonSerializerOptions, allowing IPath to be used in request/response models. Null JSON values deserialize to null.


Documentation

Full API reference: https://olivervea.github.io/Olve.Utilities/api/Olve.MinimalApi.html


License

MIT License © OliverVea

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Olve.MinimalApi:

Package Downloads
Olve.Logging

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.38.0 103 2/19/2026
0.37.2 97 2/18/2026
0.37.1 98 2/18/2026
0.37.0 89 2/17/2026
0.36.1 239 11/15/2025
0.36.0 199 11/15/2025
0.35.2 162 11/9/2025
0.35.1 151 11/8/2025
0.35.0 148 11/8/2025
0.34.0 143 10/4/2025
0.33.0 138 9/13/2025
0.32.2 217 8/9/2025
0.32.1 186 8/9/2025
0.32.0 235 8/8/2025
0.31.0 277 8/5/2025
0.30.0 120 8/3/2025