Waystone.Common.Api 2.3.0

dotnet add package Waystone.Common.Api --version 2.3.0                
NuGet\Install-Package Waystone.Common.Api -Version 2.3.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="Waystone.Common.Api" Version="2.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Waystone.Common.Api --version 2.3.0                
#r "nuget: Waystone.Common.Api, 2.3.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.
// Install Waystone.Common.Api as a Cake Addin
#addin nuget:?package=Waystone.Common.Api&version=2.3.0

// Install Waystone.Common.Api as a Cake Tool
#tool nuget:?package=Waystone.Common.Api&version=2.3.0                

Waystone.Common.Api

The foundational code required to create .NET 6 Clean Architecture API layer projects for Draekien Industries. It is intended to be used alongside:

The below sample code is the recommended usage for this library. If you wish to configure your own problem details mapping (i.e. you have your own exceptions that must be mapped to specific status codes), then see the Advanced Usage section and do not use AcceptDefaults().

// program.cs
using Waystone.Common.Api;

// after creating the web application builder
// configures serilog using appsettings and enrichers:
// - Correlation ID Header Enricher
// - Http Request Context Enricher
builder.Host
       .UseWaystoneApiHostBuilder()
       .AcceptDefaults();

// Accept the default configuration provided by Waystone.Common.Api.
// Currently adds:
// - controllers
// - route naming conventions
// - problem details
// - swagger (nswag)
// - newtonsoft configuration
// - correlation id header options
// - http request context action filter
builder.Services
       .AddWaystoneApiServiceBuilder(
           builder.Environment,
           builder.Configuration,
           typeof(Program))
       .AcceptDefault(
           apiName: "ACME",
           apiVersion: "v1",
           apiDescription: "An api for ACME");

// After creating the web application with `builder.Build()`
// Currently adds:
// - correlation id header middleware
// - https redirection
// - problem details
// - authorization
// - map controllers
// - serilog request logging
// - http request context logging middleware
app.UseWaystoneApiApplicationBuilder()
   .AcceptDefaults();

Advanced Usage

// program.cs
using Waystone.Common.Api;

// after creating the web application builder
builder.Host.UseSerilog(
    (context, provider, configuration) => 
        configuration.ReadFrom.Configuration(context.Configuration)
                     .Enrich.WithCorrelationIdHeader(builder.Configuration, provider)
                     .Enrich.WithHttpContext(provider);
);

// Manually configure Waystone.Common.Api
builder.Services
       .AddWaystoneApiServiceBuilder(
           builder.Environment,
           builder.Configuration,
           typeof(Program))
       .AddControllers()
       .AddRoutingConventions()
       .AddProblemDetails(options => { /* configure problem details */ })
       .AddSwaggerDocumentation(
           apiName: "ACME",
           apiVersion: "v1",
           apiDescription: "An api for ACME")
       .BindCorrelationIdHeaderOptions();
       
// After creating the web application with `builder.Build()`
app.UseWaystoneApiApplicationBuilder()
   .UseCorrelationIdHeaderMiddleware()
   .UseHttpContextDtoMiddleware();

app.UseHttpsRedirection();
app.UseProblemDetails();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.UseSerilogRequestLogging();
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.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
2.3.0 232 3/19/2023
2.3.0-alpha.12 85 3/19/2023
2.3.0-alpha.3 78 3/17/2023
2.3.0-alpha.1 72 3/17/2023
2.1.0 236 2/7/2023
2.1.0-alpha.19 86 2/7/2023
2.1.0-alpha.13 96 11/29/2022
2.1.0-alpha.8 82 11/28/2022
2.1.0-alpha.4 81 11/4/2022
2.1.0-alpha.1 98 6/27/2022
2.0.1 458 6/23/2022
2.0.1-alpha.3 102 6/23/2022
2.0.0 458 6/23/2022
2.0.0-alpha.9 116 6/23/2022
1.5.1-alpha.7 104 6/22/2022
1.5.1-alpha.3 103 6/22/2022
1.5.1-alpha.1 101 6/22/2022
1.5.0 451 6/22/2022
1.5.0-alpha.12 104 6/22/2022
1.5.0-alpha.7 113 6/22/2022
1.5.0-alpha.3 100 6/16/2022
1.4.0 445 6/15/2022
1.3.0-alpha.9 99 6/15/2022
1.1.0 450 6/13/2022
1.1.0-alpha.3 99 6/13/2022
1.0.2-alpha.1 104 6/13/2022
1.0.1-alpha0002.6 90 6/13/2022
1.0.1-alpha0002.5 92 6/13/2022
0.6.0-alpha0001.5 92 6/13/2022
0.5.2-alpha0002.3 97 6/13/2022