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 226 3/19/2023
2.3.0-alpha.12 77 3/19/2023
2.3.0-alpha.3 77 3/17/2023
2.3.0-alpha.1 71 3/17/2023
2.1.0 231 2/7/2023
2.1.0-alpha.19 83 2/7/2023
2.1.0-alpha.13 88 11/29/2022
2.1.0-alpha.8 81 11/28/2022
2.1.0-alpha.4 77 11/4/2022
2.1.0-alpha.1 96 6/27/2022
2.0.1 456 6/23/2022
2.0.1-alpha.3 100 6/23/2022
2.0.0 451 6/23/2022
2.0.0-alpha.9 115 6/23/2022
1.5.1-alpha.7 102 6/22/2022
1.5.1-alpha.3 100 6/22/2022
1.5.1-alpha.1 100 6/22/2022
1.5.0 449 6/22/2022
1.5.0-alpha.12 97 6/22/2022
1.5.0-alpha.7 112 6/22/2022
1.5.0-alpha.3 99 6/16/2022
1.4.0 443 6/15/2022
1.3.0-alpha.9 97 6/15/2022
1.1.0 448 6/13/2022
1.1.0-alpha.3 97 6/13/2022
1.0.2-alpha.1 102 6/13/2022
1.0.1-alpha0002.6 89 6/13/2022
1.0.1-alpha0002.5 91 6/13/2022
0.6.0-alpha0001.5 90 6/13/2022
0.5.2-alpha0002.3 95 6/13/2022