CodeKop.ServiceDefaults
1.0.2
dotnet add package CodeKop.ServiceDefaults --version 1.0.2
NuGet\Install-Package CodeKop.ServiceDefaults -Version 1.0.2
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="CodeKop.ServiceDefaults" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeKop.ServiceDefaults" Version="1.0.2" />
<PackageReference Include="CodeKop.ServiceDefaults" />
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 CodeKop.ServiceDefaults --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CodeKop.ServiceDefaults, 1.0.2"
#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.
#addin nuget:?package=CodeKop.ServiceDefaults&version=1.0.2
#tool nuget:?package=CodeKop.ServiceDefaults&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CodeKop.ServiceDefaults
A reusable library providing default service registrations, middleware, and configurations for ASP.NET Core APIs. It streamlines the setup of modern .NET APIs by bundling best practices for API documentation, error handling, telemetry, security, and more.
Features
- OpenAPI/Swagger: Automatic API documentation with JWT Bearer authentication support.
- ProblemDetails Middleware: Standardized error responses for HTTP APIs.
- Global Exception Handling: Consistent error handling via global and fallback exception handlers.
- OpenTelemetry: Distributed tracing and metrics collection with OTLP exporter.
- CORS: Pre-configured to allow any origin, header, and method.
- HTTP Context Accessor: For accessing HTTP context in services.
- Endpoints API Explorer: Supports minimal APIs and Swagger.
- Health Checks: Built-in health check endpoint.
- Serilog Logging: Structured logging with OpenTelemetry integration.
- Scalar UI: Enhanced Swagger UI for API exploration (development only).
Getting Started
Prerequisites
- .NET 9 SDK or later
Installation
Add a reference to the CodeKop.ServiceDefaults
library in your ASP.NET Core project.
Usage
1. Register Service Defaults
In your Program.cs
or wherever you configure services:
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
- FluentResults (>= 3.16.0)
- FluentResults.Extensions.AspNetCore (>= 0.1.0)
- FluentValidation (>= 12.0.0)
- FluentValidation.AspNetCore (>= 11.3.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.4)
- Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (>= 9.0.4)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 9.0.4)
- Microsoft.AspNetCore.Identity.UI (>= 9.0.4)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.AspNetCore.OpenApi (>= 9.0.4)
- Microsoft.EntityFrameworkCore (>= 9.0.4)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.4)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Http (>= 9.0.4)
- Microsoft.Extensions.Http.Resilience (>= 9.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.Extensions.ServiceDiscovery (>= 9.2.1)
- Microsoft.VisualStudio.Azure.Containers.Tools.Targets (>= 1.21.2)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.12.0)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.11.2-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.12.0)
- OpenTelemetry.Instrumentation.Http (>= 1.12.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.12.0)
- Scalar.AspNetCore (>= 2.2.7)
- Serilog (>= 4.3.0)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Extensions.Hosting (>= 9.0.0)
- Serilog.Sinks.Graylog (>= 3.1.1)
- Serilog.Sinks.OpenTelemetry (>= 4.1.1)
- Swashbuckle.AspNetCore (>= 8.1.1)
- Swashbuckle.AspNetCore.Swagger (>= 8.1.1)
- Swashbuckle.AspNetCore.SwaggerUI (>= 8.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.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 72 | 5/31/2025 |
1.0.1 | 73 | 5/31/2025 |
1.0.1-improvements0001 | 70 | 5/31/2025 |
1.0.1-ci0008 | 40 | 5/31/2025 |
1.0.0 | 43 | 5/31/2025 |