Calabonga.Utils.Endpoints
1.0.0
dotnet add package Calabonga.Utils.Endpoints --version 1.0.0
NuGet\Install-Package Calabonga.Utils.Endpoints -Version 1.0.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="Calabonga.Utils.Endpoints" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Calabonga.Utils.Endpoints" Version="1.0.0" />
<PackageReference Include="Calabonga.Utils.Endpoints" />
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 Calabonga.Utils.Endpoints --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Calabonga.Utils.Endpoints, 1.0.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.
#:package Calabonga.Utils.Endpoints@1.0.0
#: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=Calabonga.Utils.Endpoints&version=1.0.0
#tool nuget:?package=Calabonga.Utils.Endpoints&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Extensions for Endpoints (ASP.NET Core)
Simple but very helpful library that's allow to get all metadata for minimal API endpoints using OpenAPI specification.
Версия 1.0.0
- First release.
How to use
Imagine you have a minimal API with some methods (something like shown below):
public override void ConfigureApplication(WebApplication app)
{
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
var group = app.MapGroup("/weather-forecast");
group.MapGet("/secured", ([FromServices] ILogger<WeatherForecastEndpoints> logger) =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
logger.LogInformation("WeatherForecast request execute at [{Time}].", DateTime.UtcNow);
return forecast;
})
.WithName("GetWeatherForecastSecured")
.WithSummary("This is summary for WeatherForecast Method1")
.RequireAuthorization("CalabongaPolicy")
.ProducesValidationProblem(400, "application/problem+json")
.ProducesProblem(400, "application/problem+json")
.ProducesProblem(401, "application/problem+json")
.WithDescription("CalabongaDescription1")
.WithDisplayName("This is a DisplayName With for Secured")
.WithTags("Weather", "Forecast")
.WithOpenApi();
group.MapGet("/anonymous", ([FromServices] ILogger<WeatherForecastEndpoints> logger) =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
logger.LogInformation("WeatherForecast request execute at [{Time}].", DateTime.UtcNow);
return forecast;
})
.WithName("GetWeatherForecastForAll")
.WithSummary("This is summary for WeatherForecast Method2")
.AllowAnonymous()
.ProducesValidationProblem(400, "application/problem+json")
.ProducesProblem(400, "application/problem+json")
.ProducesProblem(401, "application/problem+json")
.WithDescription("CalabongaDescription2")
.WithDisplayName("This is a DisplayName With for Anonymous")
.WithTags("Weather", "Forecast", "Insecure")
.WithOpenApi();
}
When you want to see a metadata for each Endpoint
you can use current nuget. Something like this:
public class ModuleService
{
private readonly IEnumerable<EndpointDataSource> _endpointData;
public ModuleService(IEnumerable<EndpointDataSource> endpointData)
{
_endpointData = endpointData;
}
public Operation<IReadOnlyList<EndpointInfo>, string> GetInformation()
{
var endpoints = _endpointData.SelectMany(x => x.Endpoints).ToList();
if (!endpoints.Any())
{
return Operation.Error("No endpoints were found");
}
var result = new List<EndpointInfo>();
foreach (var endpoint in endpoints)
{
var isExcluded = endpoint.GetEndpointExcluded();
if (isExcluded)
{
continue;
}
var item = new EndpointInfo
(
endpoint.GetEndpointName(),
endpoint.GetRoutePatternAsRawText(),
endpoint.GetGroupName(),
endpoint.GetEndpointSummary(),
endpoint.GetDescription(),
endpoint.GetHttpMethodsInfo(),
endpoint.GetAnonymousAllowed(),
endpoint.GetAuthorizeInfo(),
endpoint.GetOpenApiInfo(),
endpoint.GetTagsInfo()
);
result.Add(item);
}
return result;
}
}
Metadata from Endpoints will look's like that:
{
"result": [
{
"name": "GetWeatherForecastSecured",
"routePattern": "/weather-forecast/secured",
"groupName": null,
"summary": "This is summary for WeatherForecast Method1",
"description": "CalabongaDescription1",
"httpMethodInfos": {
"httpMethods": [
"GET"
],
"acceptCorsPreflight": false
},
"isAllowAnonymous": false,
"authorizeInfo": {
"policy": "CalabongaPolicy",
"authenticationSchemes": null,
"roles": null
},
"openApiData": {
"description": "CalabongaDescription1",
"summary": "This is summary for WeatherForecast Method1",
"operationId": "GetWeatherForecastSecured"
},
"tags": [
"Weather",
"Forecast"
]
},
{
"name": "GetWeatherForecastForAll",
"routePattern": "/weather-forecast/anonymous",
"groupName": null,
"summary": "This is summary for WeatherForecast Method2",
"description": "CalabongaDescription2",
"httpMethodInfos": {
"httpMethods": [
"GET"
],
"acceptCorsPreflight": false
},
"isAllowAnonymous": true,
"authorizeInfo": null,
"openApiData": {
"description": "CalabongaDescription2",
"summary": "This is summary for WeatherForecast Method2",
"operationId": "GetWeatherForecastForAll"
},
"tags": [
"Weather",
"Forecast",
"Insecure"
]
}
],
"ok": true
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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.
-
net9.0
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.AspNetCore.OpenApi (>= 9.0.5)
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.0 | 306 | 5/23/2025 |
First release