MinimalApi.Results 1.0.7

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

MinimalApi.Results

NuGet Version NuGet Downloads

MinimalApi.Results is a lightweight and modular library designed to streamline response handling in .NET Minimal APIs.

It provides a consistent response structure via the ApiResponse<T> class, supports error handling in compliance with RFC7807 through ProblemDetails, integrates seamlessly with FluentValidation, and includes middleware for performance logging and execution time monitoring.

This library aims to enhance the robustness, clarity, and maintainability of Minimal API-based applications.


โœจ Key Features

  • โœ… Standardized API Responses
    Uniform return structure using ApiResponse<T> for all endpoints.

  • ๐Ÿ“Š Performance Logging Middleware
    Measure and log execution time per endpoint, with optional threshold alerting.

  • ๐Ÿงช Model Validation Integration
    Built-in support for model validation through FluentValidation via ValidationFilter<T>.


๐Ÿ“ฆ Installation

You can install the package using the .NET CLI:

dotnet add package MinimalApi.Results

Or via the Package Manager Console:

Install-Package MinimalApi.Results

๐Ÿš€ Usage Examples

Basic Usage with Standardized Response

app.MapPost("/example", async ([FromBody] MyRequest request) =>
{
    var result = DoSomething(request);
    return ApiResponse<MyResponse>.Ok(result, "/example").ToResult();
});

With Model Validation using FluentValidation

app.MapPost("/example", async ([FromBody] MyRequest request) =>
{
    var result = DoSomething(request);
    return ApiResponse<MyResponse>.Ok(result, "/example").ToResult();
})
.AddEndpointFilter<ValidationFilter<MyRequest>>();

With FluentValidation and Execution Time Monitoring

Ensure the middleware is registered in the correct order:

app.UseMiddleware<ApiResponsePostProcessorMiddleware>();
app.UseMiddleware<PerformanceLoggingMiddleware>();

app.MapPost("/example", async ([FromBody] MyRequest request) =>
{
    var result = DoSomething(request);
    return ApiResponse<MyResponse>.Ok(result, "/example").ToResult();
})
.WithMetadata(new MaxExecutionTimeAttribute(200)) // Execution time threshold in milliseconds
.AddEndpointFilter<ValidationFilter<MyRequest>>();

๐Ÿ“„ License

This project is licensed under the MIT License.


๐Ÿ™‹โ€โ™‚๏ธ Contributions

Contributions, feedback, and suggestions are welcome. Please feel free to open issues or submit pull requests to help improve the project.

Product 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 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.7 320 7/17/2025
1.0.6 140 7/17/2025
1.0.4 139 7/17/2025