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" />
                    
Directory.Packages.props
<PackageReference Include="CodeKop.ServiceDefaults" />
                    
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 CodeKop.ServiceDefaults --version 1.0.2
                    
#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
                    
Install CodeKop.ServiceDefaults as a Cake Addin
#tool nuget:?package=CodeKop.ServiceDefaults&version=1.0.2
                    
Install CodeKop.ServiceDefaults as a Cake Tool

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 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.

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