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
                    
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="AlefCarlos.AspNetCoreDefaults.WebApi.All" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlefCarlos.AspNetCoreDefaults.WebApi.All" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AlefCarlos.AspNetCoreDefaults.WebApi.All" />
                    
Project file
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 AlefCarlos.AspNetCoreDefaults.WebApi.All --version 1.0.1
                    
#r "nuget: AlefCarlos.AspNetCoreDefaults.WebApi.All, 1.0.1"
                    
#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 AlefCarlos.AspNetCoreDefaults.WebApi.All@1.0.1
                    
#: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=AlefCarlos.AspNetCoreDefaults.WebApi.All&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AlefCarlos.AspNetCoreDefaults.WebApi.All&version=1.0.1
                    
Install as a Cake Tool

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 OpenApiInfo a partir de ApplicationMetadata
    • registra transformadores de OpenAPI (OpenApiInfoTransformer)
  • void UseProblemDetailsWithDefaults(this WebApplication app)

    • configura UseExceptionHandler() e UseStatusCodePages()
    • habilita UseDeveloperExceptionPage() em Development
  • WebApplication MapDefaultWebApiEndpoints(this WebApplication app)

    • mapeia endpoints padrão: /health, /alive, /app-info
    • mapeia OpenAPI (MapOpenApi()) e referência de API (MapScalarApiReference("/docs"))
  • 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 → retorna ApplicationMetadata (excluído da documentação via ExcludeFromDescription())

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 110 12/26/2025
1.0.0 120 12/24/2025
0.0.1-rc8 113 12/24/2025
0.0.1-rc7 107 12/24/2025
0.0.1-rc6 113 12/24/2025