Danom.MinimalApi
2.1.1
dotnet add package Danom.MinimalApi --version 2.1.1
NuGet\Install-Package Danom.MinimalApi -Version 2.1.1
<PackageReference Include="Danom.MinimalApi" Version="2.1.1" />
<PackageVersion Include="Danom.MinimalApi" Version="2.1.1" />
<PackageReference Include="Danom.MinimalApi" />
paket add Danom.MinimalApi --version 2.1.1
#r "nuget: Danom.MinimalApi, 2.1.1"
#:package Danom.MinimalApi@2.1.1
#addin nuget:?package=Danom.MinimalApi&version=2.1.1
#tool nuget:?package=Danom.MinimalApi&version=2.1.1
Danom.MinimalApi
Danom.MinimalApi is a library that provides a set of utilities to help integrate the Danom library with common tasks in ASP.NET Core Minimal API applications.
Key Features
- Extension methods for converting
Option<T>andResult<T, TError>types toIResultresponses. - Support for both standard and typed results in Minimal APIs.
Design Goals
- Simplify the handling of optional and result-based data in Minimal APIs.
- Provide a clean and intuitive API for developers familiar with Danom and ASP.NET Core.
Getting Started
Install the Danom.MinimalApi NuGet package:
PM> Install-Package Danom.MinimalApi
Or using the dotnet CLI
dotnet add package Danom.MinimalApi
Basic Usage
Returning Option
- Some: Returns
200 OKwith the value. - None: Return
404 Not Found(or a custom result, if provided).
app.MapGet("/user/{id}", (int id) => {
var user = FindUser(id);
return Results.Extensions.Option(user);
});
Or, with a custom result:
app.MapGet("/user/{id}", (int id) => {
var user = FindUser(id);
return Results.Extensions.Option(user, () => Results.Conflict());
});
Returning Result
- Ok: Returns
200 OKwith the value. - Error: Returns
400 Bad Request(or a customIResult, if provided).
app.MapPost("/user", (User user) => {
var result = TryCreateUser(user);
return Results.Extensions.Result(result);
});
Or, with a custom result:
app.MapPost("/user", (User user) => {
var result = TryCreateUser(user);
return Results.Extensions.Result(result, error => Results.UnprocessableEntity());
});
Typed Results
If you want to use ASP.NET Core's typed results, Danom.MinimalApi provides additional extension methods.
Returning Typed Option
- Some: Returns
OptionHttpResult<T>and200 OK. - None: Returns
OptionHttpResult<T>and404 Not Found(or a customIResult, if provided).
using Danom;
using Danom.MinimalApi;
app.MapGet("/user/{id}", (int id) => {
var user = FindUser(id);
return DanomTypedResults.Option(user);
});
// or, with a custom error handler
app.MapGet("/user/{id}/custom", (int id) => {
var user = FindUser(id);
return DanomTypedResults.Option(user,
noneResult: () => Results.NotFound("Custom not found!"));
});
Returning Typed Result
- Ok: Returns
ResultHttpResult<T, TError>and200 OK. - Error: Returns
ResultHttpResult<T, TError>and400 Bad Request
using Danom;
using Danom.MinimalApi;
app.MapPost("/user", (User user) => {
var result = TryCreateUser(user);
return DanomTypedResults.Result(result);
});
// or, with a custom error handler
app.MapPost("/user/custom", (User user) => {
var result = TryCreateUser(user);
return DanomTypedResults.Result(result,
errorResult: error => Results.Ok(new { Message = "There was a problem", error }));
});
// or, return a problem details response
app.MapPost("/user/problem", (User user) => {
var result = TryCreateUser(user);
return DanomTypedResults.ResultProblem(result);
});
Contributing
I kindly ask that before submitting a pull request, you first submit an issue.
If functionality is added to the API, or changed, please kindly update the relevant documentation. Unit tests must also be added and/or updated before a pull request can be successfully merged.
Only pull requests which pass all build checks and comply with the general coding standard can be approved.
Find a bug?
There's an issue for that.
License
Licensed under MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
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.1.1 | 89 | 1/5/2026 |
| 2.1.0 | 92 | 12/30/2025 |
| 2.0.0 | 317 | 9/17/2025 |
| 2.0.0-beta4 | 199 | 6/24/2025 |