Nomad.Common.MinimalApi 1.0.0

dotnet add package Nomad.Common.MinimalApi --version 1.0.0
                    
NuGet\Install-Package Nomad.Common.MinimalApi -Version 1.0.0
                    
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="Nomad.Common.MinimalApi" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nomad.Common.MinimalApi" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Nomad.Common.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 Nomad.Common.MinimalApi --version 1.0.0
                    
#r "nuget: Nomad.Common.MinimalApi, 1.0.0"
                    
#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 Nomad.Common.MinimalApi@1.0.0
                    
#: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=Nomad.Common.MinimalApi&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nomad.Common.MinimalApi&version=1.0.0
                    
Install as a Cake Tool

Nomad.Common.MinimalApi

A clean and efficient framework for building Minimal API endpoints in ASP.NET Core using use cases and the Result pattern. Designed to keep HTTP interfaces thin, modular, and focused on business logic โ€” not plumbing.


โœจ Features

  • ๐Ÿงฉ Endpoint-first design with IEndpointModule
  • ๐Ÿš€ Auto-discovery of endpoint modules from the entry assembly
  • โœ… Native support for Result / Result<T> return types
  • ๐Ÿ” Smart HTTP status code mapping: 200, 201, 204, 400, 404, 409, etc.
  • ๐Ÿงผ Minimal allocations, no magic, no reflection
  • ๐Ÿ”Œ Seamlessly integrates with IUseCaseDispatcher (Clean Architecture)

๐Ÿ“ฆ Installation

dotnet add package Nomad.Common.MinimalApi

๐Ÿš€ Quick Example

1. Create a Use Case

public class CreateProductUseCase : IUseCase<CreateProductRequest, Result<ProductResponse>>
{
    public Task<Result<ProductResponse>> ExecuteAsync(CreateProductRequest request, CancellationToken cancellationToken = default)
    {
        var product = new ProductResponse { Id = Guid.NewGuid(), Name = request.Name };
        return Task.FromResult(Result.Success(product));
    }
}

2. Define Endpoint Module

public class ProductEndpoints : IEndpointModule
{
    public void RegisterEndpoints(IEndpointRouteBuilder app)
    {
        app.MapUseCasePost<CreateProductRequest, ProductResponse>(
            "/products", created => $"/products/{created.Id}");
    }
}

3. Register in Program.cs

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddUseCases(typeof(CreateProductUseCase).Assembly)
    .AddEndpointModulesFromEntryAssembly();

var app = builder.Build();

app.MapEndpointModulesFromEntryAssembly();

app.Run();

๐Ÿง  Smart HTTP Mapping

The library maps domain-level results to proper HTTP responses:

Result HTTP Response
Result.Success() 200 OK
Result<T>.Success(...) 200 OK (with body)
MapUseCasePost(..., routeFactory) 201 Created (with Location header)
Result.Failure(...) 400 / 404 / 409 (based on error code)
Result.NotFound() 404 Not Found

โœ… When to Use

  • You use Minimal APIs with Clean Architecture
  • You want consistent and testable HTTP endpoints
  • You want to avoid controller overload and infrastructure leakage
  • You prefer business logic to live in UseCases, not endpoints

๐Ÿ“„ License

MIT License ยท ยฉ Nomad

All feedback and contributions are welcome.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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

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
1.0.0 219 4/14/2025