AlefCarlos.AspNetCoreDefaults.WebApi.All
1.0.1
dotnet add package AlefCarlos.AspNetCoreDefaults.WebApi.All --version 1.0.1
NuGet\Install-Package AlefCarlos.AspNetCoreDefaults.WebApi.All -Version 1.0.1
<PackageReference Include="AlefCarlos.AspNetCoreDefaults.WebApi.All" Version="1.0.1" />
<PackageVersion Include="AlefCarlos.AspNetCoreDefaults.WebApi.All" Version="1.0.1" />
<PackageReference Include="AlefCarlos.AspNetCoreDefaults.WebApi.All" />
paket add AlefCarlos.AspNetCoreDefaults.WebApi.All --version 1.0.1
#r "nuget: AlefCarlos.AspNetCoreDefaults.WebApi.All, 1.0.1"
#:package AlefCarlos.AspNetCoreDefaults.WebApi.All@1.0.1
#addin nuget:?package=AlefCarlos.AspNetCoreDefaults.WebApi.All&version=1.0.1
#tool nuget:?package=AlefCarlos.AspNetCoreDefaults.WebApi.All&version=1.0.1
AspNetCoreDefaults.WebApi.All 🔧
Biblioteca de convenções e extensões para padronizar Web APIs ASP.NET Core (OpenAPI, ProblemDetails, health checks, logging e OpenTelemetry).
Objetivo
Fornecer um conjunto mÃnimo e opinativo de defaults para projetos Web API, facilitando:
- padronização de endpoints (health, alive, app-info)
- integração e configuração de OpenAPI (via
Microsoft.AspNetCore.OpenApi+Scalar.AspNetCore) - tratamento de erros com
ProblemDetails - configuração de logging HTTP e filtros para endpoints sensÃveis
- instrumentação OpenTelemetry (tracing e métricas)
APIs principais
WebApplicationBuilder AddWebApiDefaults(this WebApplicationBuilder builder)- chama
AddDefaults()(telemetria, health checks, logging, service discovery) - adiciona
ProblemDetails - registra
OpenApiInfoa partir deApplicationMetadata - registra transformadores de OpenAPI (
OpenApiInfoTransformer)
- chama
void UseProblemDetailsWithDefaults(this WebApplication app)- configura
UseExceptionHandler()eUseStatusCodePages() - habilita
UseDeveloperExceptionPage()emDevelopment
- configura
WebApplication MapDefaultWebApiEndpoints(this WebApplication app)- mapeia endpoints padrão:
/health,/alive,/app-info - mapeia OpenAPI (
MapOpenApi()) e referência de API (MapScalarApiReference("/docs"))
- mapeia endpoints padrão:
WebApplication MapDefaultEndpoints(this WebApplication app)(do pacote base)- configuração de health checks:
/health→ readiness (todos checks)/alive→ liveness (apenas checks com tag"live")
GET /app-info→ retornaApplicationMetadata(excluÃdo da documentação viaExcludeFromDescription())
- configuração de health checks:
Exemplo rápido (Program.cs)
var builder = WebApplication.CreateBuilder(args);
// Configura defaults opinativos para WebApi (telemetria, logging, health checks, OpenAPI)
builder.AddWebApiDefaults();
// Personalize OpenAPI se desejar
builder.Services.Configure<OpenApiInfo>(opts => opts.Description = "Descrição detalhada da API");
var app = builder.Build();
app.UseHttpLogging();
app.UseProblemDetailsWithDefaults();
app.MapGet("/", () => new { Message = "Hello, World!" }).WithName("HelloWorld");
// Mapeia endpoints padrão + OpenAPI + docs
app.MapDefaultWebApiEndpoints();
app.Run();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- AlefCarlos.AspNetCoreDefaults.WebApi (>= 1.0.1)
- FluentValidation.DependencyInjectionExtensions (>= 12.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.