SI.Endpoints 1.2.0

dotnet add package SI.Endpoints --version 1.2.0
NuGet\Install-Package SI.Endpoints -Version 1.2.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="SI.Endpoints" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SI.Endpoints --version 1.2.0
#r "nuget: SI.Endpoints, 1.2.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.
// Install SI.Endpoints as a Cake Addin
#addin nuget:?package=SI.Endpoints&version=1.2.0

// Install SI.Endpoints as a Cake Tool
#tool nuget:?package=SI.Endpoints&version=1.2.0

SI.Endpoints

NuGet NuGet NuGet Quality Gate Status Coverage

Introduction

Have fun using this lightweight endpoint API library. No more bloated Program.cs files and no more bloated Controllers. This library is in between those two.

Getting Started

1. Install and reference the NuGet package

Install-Package SI.Endpoints

2. Register the Endpoints

services.AddControllers();
services.AddEndpointsRouting();

3. Create your first Endpoint and have fun

// DTOs
public record SayHelloRequest(string Name);
public record SayHelloResponse(string Message);

// Endpoint
public class SayHello : Endpoint<SayHelloRequest, SayHelloResponse>
{
    [HttpPost]
    public override ActionResult<SayHelloResponse> Handle(SayHelloRequest request)
    {
        return new SayHelloResponse("Hello " + request.Name);
    }
}

Check out your first endpoint and navigate to: <uri>/SayHello?Name=World!

Optionally Configure your endpoints

services.AddControllers();
services.AddEndpointsRouting(options =>
{
    options.UseFeatures();              // Groups endpoints by the same last namespace part
    options.WithPrefix("Ultra-Api");    // Adds the given prefix name to all endpoint routes
});

The following example shows how endpoints are configured with the given configuration:

MyApp.Endpoints.Messaging.HelloEndpoint            // <uri>/Ultra-Api/Messaging/SayHello
MyApp.Endpoints.Messaging.SayGoodByeEndpoint       // <uri>/Ultra-Api/Messaging/SayGoodBye
MyApp.AnotherEndpointNamespace.Calculate.Multiply  // <uri>/Ultra-Api/Calculate/Multiply
MyApp.AnotherEndpointNamespace.Calculate.Subtract  // <uri>/Ultra-Api/Calculate/Subtract

Use the Swagger integration

If you use swagger, then you will see that every endpoint is grouped separetly. If you want to group them by feature (like a standard controller in mvc), then simply enable the feature filter.

A. Using Swashbuckle

1. Install the NuGet-Package

Install-Package SI.Endpoints.Swagger

2. Add EnableAnnotations() and EnableFeatureFilter() to the Swagger configuration

services.AddControllers();
services.AddEndpointsRouting(options => options.UseFeatures() });

// Add swagger
services.AddSwaggerGen(options =>
{
    options.EnableAnnotations();    // Make use of the Annotations
    options.EnableFeatureFilter();  // Automatically group endpoints by the [feature] template
    options.SwaggerDoc("v1", new OpenApiInfo { Title = "Sample endpoints", Version = "v1" });
});

B. Using NSwag

1. Install the NuGet-Package

Install-Package SI.Endpoints.NSwag

2. Add EnableAnnotations() and EnableFeatureFilter() to the Swagger configuration

services.AddControllers();
services.AddEndpointsRouting(options => options.UseFeatures() });

// Add swagger
services.AddOpenApiDocument(options => options.EnableFeatureFilter()); // Option A
services.AddSwaggerDocument(options => options.EnableFeatureFilter()); // Option B

Open Source License Acknowledgements and Third-Party Copyrights

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SI.Endpoints:

Package Downloads
SI.Endpoints.Swagger

Simple ASP.NET Core API Endpoints - Swagger integration for SI.Endpoints.

SI.Endpoints.NSwag

Simple ASP.NET Core API Endpoints - NSwag integration for SI.Endpoints.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 858 1/30/2023
1.1.0 1,019 11/20/2022
1.0.0 1,028 11/17/2022
0.1.0 1,203 10/6/2020