Bsft.Hosting.OpenApi 2.3.0

dotnet add package Bsft.Hosting.OpenApi --version 2.3.0
                    
NuGet\Install-Package Bsft.Hosting.OpenApi -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="Bsft.Hosting.OpenApi" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bsft.Hosting.OpenApi" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Bsft.Hosting.OpenApi" />
                    
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 Bsft.Hosting.OpenApi --version 2.3.0
                    
#r "nuget: Bsft.Hosting.OpenApi, 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.
#:package Bsft.Hosting.OpenApi@2.3.0
                    
#: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=Bsft.Hosting.OpenApi&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Bsft.Hosting.OpenApi&version=2.3.0
                    
Install as a Cake Tool

Bsft.Hosting.OpenApi

The OpenAPI and API-versioning part of the BSFT host defaults: Swashbuckle document generation, URL-segment API versioning, and the one-call AddBsftDefaults / UseBsftDefaults that registers them together with every Bsft.Hosting component and orders the middleware.

Install

dotnet add package Bsft.Hosting.OpenApi

Requires Bsft.Hosting (pulled transitively), Swashbuckle.AspNetCore and Asp.Versioning.Mvc.ApiExplorer. They live here rather than in Bsft.Hosting so that a host that pins its own Swashbuckle version can take CORS, rate limiting and health checks from Bsft.Hosting without this package.

Register

using Bsft.Hosting.OpenApi.DependencyInjection;

services.AddBsftCorrelation();
services.AddBsftDefaults(defaults => defaults
    .Swagger(swagger => swagger.Title = "Orders API")
    .Cors(cors => cors.AllowOrigins("https://app.example.com").AllowCredentials()));

// or bound from configuration, sections "Bsft:Hosting:*"
services.AddBsftDefaults(configuration);
app.UseBsftDefaults();

AddBsftCorrelation() is not optional: UseBsftDefaults() puts UseBsftCorrelation() into the pipeline but does not register its services. The error middleware that UseBsftDefaults() adds takes ICorrelationContext per request to stamp the correlation id on the ProblemDetails, so without the registration the first request fails to resolve it instead of producing the error response. UseBsftDefaults() adds, in this order, HTTPS redirection, correlation, the exception middleware, rate limiting, CORS, compression, Swagger and health checks.

A host that composes the pipeline itself takes AddBsftSwagger / UseBsftSwagger and AddBsftApiVersioning from this package and the remaining pairs from Bsft.Hosting.DependencyInjection.

The one call always brings Swashbuckle and Asp.Versioning at the versions this package is built against; that is the deliberate price of the convenience. A host that pins its own Swashbuckle version does not reference this package: it takes Bsft.Hosting alone and calls the component pairs it wants, in the order listed above.

Configure

Option Default Effect
BsftSwaggerOptions.Title (Bsft:Hosting:Swagger) entry assembly name Document title. Must not be blank.
BsftSwaggerOptions.Version "v1" Document version, and the document's name. Must not be blank.
BsftSwaggerOptions.IsBearerAuthEnabled false Adds the bearer scheme. AddBearerAuth() is the fluent way of setting it.
BsftSwaggerOptions.IncludesXmlComments true Feeds every XML doc file next to the assembly into the document.
BsftVersioningOptions.DefaultVersion (Bsft:Hosting:Versioning) 1.0 Whole part is the major, first decimal the minor. Not negative.
BsftVersioningOptions.ShouldAssumeDefaultVersionWhenUnspecified true Unversioned requests get the default.
BsftVersioningOptions.ShouldReportApiVersions true Reports available versions in response headers.

The other Bsft:Hosting:* sections AddBsftDefaults binds are the Bsft.Hosting components' own, listed in that package's README.

Validation: on start, a blank Swagger title or version and a negative default API version are each rejected, naming the member.

UseBsftSwagger serves the document and the Swagger UI under /swagger in the Development environment only, and redirects / there.

Extend

None. Swashbuckle's own AddSwaggerGen options and Asp.Versioning's options stay open to a host that configures them after this package.

Documentation

Topic page: docs/hosting.md. Conventions: docs/package-conventions.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  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 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
2.3.0 60 11/27/2026