📌 ETPackages.Endpoints
ETPackages.Endpoints is a lightweight extension library designed to make .NET 6+ Minimal API endpoints more readable, organized, and reusable.
- ✅ Minimal API support
- ✅ Define endpoints in separate classes implementing
IEndpoint - ✅ Auto-discover and map endpoints with
AddEndpoints()andMapEndpoints() - ✅ Support for single or multiple assemblies
- ✅ Cleaner code with extension methods
- ✅ Easily testable and extendable
- ✅ Full Swagger / OpenAPI compatibility
- Cleaner
Program.cs
No more huge lists ofapp.MapGet(...)calls. - Separation of concerns
Each endpoint lives in its own class. - Auto-discovery
Endpoints are automatically discovered and mapped. - Testability
Endpoints can be tested independently. - Scalability
Easy to maintain even in large projects.
- .NET 6.0 or higher
Install via NuGet:
Install-Package ETPackages.Endpoints
Or via the .NET Core command line interface:
dotnet add package ETPackages.Endpoints
using ETPackages.Endpoints;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpoints(typeof(Program).Assembly);
var app = builder.Build();
// Use the extension method to map endpoints
app.MapEndpoints();
app.Run();using Microsoft.AspNetCore.Routing;
using ETPackages.Endpoints;
public class UserEndpoints : IEndpoint
{
public void MapEndpoints(IEndpointRouteBuilder builder)
{
var group = builder
.MapGroup("/users")
.WithTags("Users");
group.MapGet("/", () => Results.Ok("Get all users"));
group.MapPost("/", () => Results.Ok("Create user"));
}
}This project includes a dedicated test project located in:
tests/ETPackages.Endpoints.Tests
dotnet test
dotnet test -v n
dotnet test --filter "FullyQualifiedName~ETPackages.Endpoints.Tests.EndpointTests"
- Tests use xUnit + FluentAssertions for better readability.
- Microsoft.AspNetCore.Mvc.Testing and TestServer are used to run in-memory Minimal API applications.
- Covered scenarios:
- Endpoint discovery (AddEndpoints)
- Single & multiple endpoints mapping
- Duplicate endpoint conflict
- No endpoints case (graceful handling)
Fork the repository
Create a new branch (feature/xyz)
Commit your changes
Open a pull request
This project is licensed under the MIT License. ,