MinimalApiBuilder 1.4.0
See the version list below for details.
dotnet add package MinimalApiBuilder --version 1.4.0
NuGet\Install-Package MinimalApiBuilder -Version 1.4.0
<PackageReference Include="MinimalApiBuilder" Version="1.4.0" />
<PackageVersion Include="MinimalApiBuilder" Version="1.4.0" />
<PackageReference Include="MinimalApiBuilder" />
paket add MinimalApiBuilder --version 1.4.0
#r "nuget: MinimalApiBuilder, 1.4.0"
#:package MinimalApiBuilder@1.4.0
#addin nuget:?package=MinimalApiBuilder&version=1.4.0
#tool nuget:?package=MinimalApiBuilder&version=1.4.0
MinimalApiBuilder
Reflectionless, source-generated, thin abstraction layer over the ASP.NET Core Minimal APIs interface.
How to Use
Based on the Vertical Slice Architecture with Feature folder.
There is one class for every API endpoint. A basic example looks like the following:
using Microsoft.AspNetCore.Mvc;
using MinimalApiBuilder;
public partial class BasicEndpoint : MinimalApiBuilderEndpoint
{
private static string Handle([FromServices] BasicEndpoint endpoint)
{
return "Hello, World!";
}
}
The endpoint class must be partial, inherit from MinimalApiBuilderEndpoint,
and have a Handle or HandleAsync method with the containing type passed
from dependency injection.
The endpoint is mapped through the typical IEndpointRouteBuilder Map<Verb> extension methods:
app.MapGet<BasicEndpoint>("/hello");
The above is functionally equivalent to:
app.MapGet("/hello", static () => "Hello, World!");
This library depends on FluentValidation >= 11. An endpoint
can have a validated request object:
public struct BasicRequest
{
public required string Name { get; init; }
}
public partial class BasicRequestEndpoint : MinimalApiBuilderEndpoint
{
private static string Handle([FromServices] BasicRequestEndpoint endpoint,
[AsParameters] BasicRequest request)
{
return $"Hello, {request.Name}!";
}
}
public class BasicRequestValidator : AbstractValidator<BasicRequest>
{
public BasicRequestValidator()
{
RuleFor(static request => request.Name).MinimumLength(2);
}
}
app.MapGet<BasicRequestEndpoint>("/hello/{name}");
The incremental generator will generate code to validate the request object before the handler is called and return
a 400 Bad Request response if the validation fails. In Program.cs the below
builder.Services.AddMinimalApiBuilderEndpoints();
needs to be added to register the necessary types with dependency injection.
Configuration
Users can add configuration through entries in .editorconfig or with MSBuild properties.
The following options are available:
minimalapibuilder_assign_name_to_endpoint (true | false)
If true, the generator will add a unique public const string Name field
to the endpoint classes and call the WithName extension method when mapping them.
minimalapibuilder_assign_name_to_endpoint = true
<PropertyGroup>
<minimalapibuilder_assign_name_to_endpoint>true</minimalapibuilder_assign_name_to_endpoint>
</PropertyGroup>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
-
net7.0
- FluentValidation (>= 11.0.0)
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 |
|---|---|---|
| 5.0.0-beta.10 | 165 | 1/25/2024 |
| 5.0.0-beta.9 | 120 | 1/22/2024 |
| 5.0.0-beta.8 | 130 | 1/3/2024 |
| 5.0.0-beta.7 | 126 | 12/29/2023 |
| 5.0.0-beta.6 | 109 | 12/18/2023 |
| 5.0.0-beta.5 | 113 | 12/15/2023 |
| 5.0.0-beta.4 | 122 | 11/27/2023 |
| 5.0.0-beta.3 | 135 | 11/23/2023 |
| 5.0.0-beta.2 | 100 | 11/23/2023 |
| 5.0.0-beta.1 | 138 | 11/21/2023 |
| 4.0.0 | 335 | 11/12/2023 |
| 3.1.0 | 159 | 11/8/2023 |
| 3.0.1 | 153 | 11/6/2023 |
| 3.0.0 | 256 | 11/6/2023 |
| 2.0.0 | 184 | 10/30/2023 |
| 1.4.0 | 189 | 10/27/2023 |
| 1.3.3 | 365 | 5/11/2023 |
| 1.3.2 | 218 | 5/8/2023 |
| 1.3.1 | 229 | 5/8/2023 |
| 1.3.0 | 214 | 5/8/2023 |
| 1.2.0 | 253 | 5/6/2023 |
| 1.1.0 | 262 | 5/1/2023 |
| 1.0.1 | 447 | 2/10/2023 |
| 1.0.0 | 452 | 1/5/2023 |
| 0.1.0-beta.12 | 181 | 1/5/2023 |
| 0.1.0-beta.11 | 201 | 1/5/2023 |
| 0.1.0-beta.10 | 173 | 1/5/2023 |
| 0.1.0-beta.9 | 196 | 1/5/2023 |
| 0.1.0-beta.8 | 212 | 1/5/2023 |
| 0.1.0-beta.7 | 212 | 1/4/2023 |
| 0.1.0-beta.6 | 185 | 1/4/2023 |
| 0.1.0-beta.5 | 207 | 1/4/2023 |
| 0.1.0-beta.4 | 186 | 1/4/2023 |
| 0.1.0-beta.3 | 185 | 1/4/2023 |
| 0.1.0-beta.2 | 194 | 12/31/2022 |
| 0.1.0-beta.1 | 266 | 12/30/2022 |