![]() |
VOOZH | about |
dotnet add package VerticalApi --version 2025.1.8.175842
NuGet\Install-Package VerticalApi -Version 2025.1.8.175842
<PackageReference Include="VerticalApi" Version="2025.1.8.175842" />
<PackageVersion Include="VerticalApi" Version="2025.1.8.175842" />Directory.Packages.props
<PackageReference Include="VerticalApi" />Project file
paket add VerticalApi --version 2025.1.8.175842
#r "nuget: VerticalApi, 2025.1.8.175842"
#:package VerticalApi@2025.1.8.175842
#addin nuget:?package=VerticalApi&version=2025.1.8.175842Install as a Cake Addin
#tool nuget:?package=VerticalApi&version=2025.1.8.175842Install as a Cake Tool
VerticalApi is intended to be a simple implementation of Vertical slicing and Minimal Api at the same time.
By allowing simplistic folder structure and a minimal amount of boilerplate code it creates an easy way to setup individual endpoints and maintaining them over time.
In the following example all endpoints relevant to public access will be mapped.
This is done by setting the property NamespaceRoot to endpoints/public.
The setting will map all found endpoints contained in the ApplicationNameSpace.endpoints.public
app.MapEndpoints(new EndpointOptions()
{
NamespaceRoot = "endpoints/public",
ApiBasePath = "api/public",
});
Reflects the root of the namespace desired to be mapped.
Example: ApplicationNamespace.Area.Endpoints can be mapped with area/endpoints
Example: ApplicationNamespace.Endpoints.Public can be mapped with endpoints/public
Sets the base path for the mapped endpoint.
Example: api/public will become https://domain.com/api/public/*
Example: endpoints/public will become https://domain.com/endpoints/public/*
If endpoints in the mapping should be authorized, set this to true.
It is necessary for app.UseAuthorization() to be called before mapping for authorization to be enabled.
Note: The [AllowAnonymous] attribute will override the authorization requirement on individual endpoints
Set the desired authentication scheme that should apply to the given endpoints.
Note: Requires the RequireAuthorization attribute to be enabled, as well as app.UseAuthentication()
Sets the name for the Cors policy to be used with the mapped endpoints.
Note: Requires app.UseCors() to be set.
The endpoint file will consist of a class containing one or more methods that can be mapped as endpoints.
These methods must always be public and static in order for them to be mapped.
Everything else is considered private methods.
namespace SolutionName.Endpoints.Public.Articles;
[Endpoint]
public static class GetByIdEndpoint {
public static async Task<Article> Get(
[FromRoute] int Id,
[FromServices] DataContext context,
CancellationToken cancellationToken)
{
var article = await context.Articles.FirstAsync(article => article.Id == Id, cancellationToken);
return article;
}
}
One of the intentions for VerticalApi is to simplify folder structures and assist in making it easier to create a simple edition of vertical slicing.
Below is an example of how a folder structure could be set up.
SolutionName
- Endpoints
- Public
- Articles
- GetById
| GetById.cs
- Dtos
| GetByIdResponse.cs
- Tests
| GetByIdTest.cs
The structure allows for segmentation of the endpoint logic from the DTOs, Mappers, Helpers and other logic that ties in closely to the endpoint.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2025.1.8.175842 | 293 | 1/8/2025 |
| 2025.1.6.125359 | 252 | 1/6/2025 |
| 2024.12.23.171334 | 255 | 12/23/2024 |
| 2024.12.23.164154 | 243 | 12/23/2024 |
| 2024.12.23.141221 | 238 | 12/23/2024 |
| 2024.12.18.143611 | 275 | 12/18/2024 |
| 2024.12.18.130833 | 258 | 12/18/2024 |
| 2024.12.9.170246 | 241 | 12/9/2024 |
| 2024.12.8.170321 | 244 | 12/8/2024 |
| 2024.12.7.222746 | 253 | 12/7/2024 |
| 2024.12.7.191425 | 268 | 12/7/2024 |
| 2024.12.7.110147 | 266 | 12/7/2024 |
| 2024.12.3.214123 | 255 | 12/3/2024 |
| 2023.11.14.1420 | 305 | 11/14/2023 |
| 2023.11.13.235409 | 239 | 11/13/2023 |
| 2023.11.13.234435 | 235 | 11/13/2023 |
| 2023.11.13.232646 | 238 | 11/13/2023 |
| 2023.11.13.204258 | 228 | 11/13/2023 |
| 2023.5.12.124206 | 2,233 | 5/12/2023 |
| 2023.5.10.133233 | 347 | 5/10/2023 |