Anarchy.Toolkit.Runtime.Web.Swagger
1.0.0
dotnet add package Anarchy.Toolkit.Runtime.Web.Swagger --version 1.0.0
NuGet\Install-Package Anarchy.Toolkit.Runtime.Web.Swagger -Version 1.0.0
<PackageReference Include="Anarchy.Toolkit.Runtime.Web.Swagger" Version="1.0.0" />
<PackageVersion Include="Anarchy.Toolkit.Runtime.Web.Swagger" Version="1.0.0" />
<PackageReference Include="Anarchy.Toolkit.Runtime.Web.Swagger" />
paket add Anarchy.Toolkit.Runtime.Web.Swagger --version 1.0.0
#r "nuget: Anarchy.Toolkit.Runtime.Web.Swagger, 1.0.0"
#:package Anarchy.Toolkit.Runtime.Web.Swagger@1.0.0
#addin nuget:?package=Anarchy.Toolkit.Runtime.Web.Swagger&version=1.0.0
#tool nuget:?package=Anarchy.Toolkit.Runtime.Web.Swagger&version=1.0.0
Anarchy.Toolkit.Runtime.Web.Swagger
Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Runtime · Package catalog
Swagger/OpenAPI for toolkit REST APIs: the OpenAPI document and the themed Swagger UI.
dotnet add package Anarchy.Toolkit.Runtime.Web.Swagger
AddToolkitSwagger(apiName, appSettings, environment, ...)registers the OpenAPI 3.2 document atswagger/spec/swagger.jsonand serves Swagger UI at/swagger, withGET /redirecting to it.- The document declares an
oauth2client-credentials scheme when the settings implementIAuthServiceAppSettings, documents[Authorize]policies (AuthorizeCheckOperationFilter) and theAccept-Encodingheader (AcceptEncodingHeaderOperationFilter), describes the runtime (SwaggerDescriptionBuilder,SwaggerDescriptionOptions) and adds a server fromBASE_PATH. - Hosts composing their own pipeline call
AddToolkitSwaggerGen(...)andapp.UseToolkitSwagger(...)instead.
When to use it
Use it for REST APIs that publish an OpenAPI document or a Swagger UI. APIs without them only need Anarchy.Toolkit.Runtime.Web, which references neither Swashbuckle nor Microsoft.OpenApi. anarchy-toolkit scaffold api adds it unless --no-swagger is given.
How to use it
public sealed class Startup(IWebHostEnvironment environment, IConfiguration configuration)
: RestApiWebAppStartupBase<ModuleAppSettings, AppSettings>(environment, configuration)
{
protected override string ApiName => "Orders API";
protected override IServiceCollection ConfigureWebCustomServices(IServiceCollection services) =>
base.ConfigureWebCustomServices(services)
.AddToolkitSwagger(ApiName, AppSettings, Environment, titlePrefix: "[Orders]");
}
oauthScopes lists the scopes offered by the Swagger UI client-credentials flow, titlePrefix (default [API]) prefixes the document and page titles, and descriptionOptions adds repository, dashboard, documentation and team links to the description.
Swagger UI theme
Swagger UI is themed by default, with the Anarchy palette, header logo (dark text in light mode, white text in dark mode) and favicon, in light and dark mode. Swagger UI starts in dark mode when the system prefers it; the choice made with its header toggle is remembered in the browser. The theme is a mechanism rather than a brand: the stylesheet reads every colour, font and radius from a separate colours stylesheet, so you can rebrand by changing only the colours.
- Change the colours. Copy
wwwroot/css/swagger-colors.cssto your API project'swwwroot/css/swagger-colors.cssand edit the values. Each colour is alight-dark(<light>, <dark>)pair. The packaged assets follow the usualwwwrootlayout (css/swagger-colors.css,css/swagger-theme.cssandjs/swagger-theme.jsin this package;images/logo.png,images/logo-dark.png, andfavicon.svgandfavicon.pngat the root inAnarchy.Toolkit.Runtime.Web), and files in your API project'swwwrootare served first, so awwwroot/favicon.svgorwwwroot/images/logo.pngreplaces the packaged one the same way. - Point elsewhere.
services.Configure<SwaggerThemeOptions>(...)setsColorsStylesheet,Stylesheet,Script,Logo,DarkLogo,FaviconandFallbackFavicon(relative to the application base path, or absolute). SetStylesheetto your own file to replace the theme entirely. - Turn it off.
services.Configure<SwaggerThemeOptions>(theme => theme.Enabled = false)keeps Swagger UI's own look and favicon.
The theme uses system fonts only and changes colours, type and borders, not layouts. Swagger UI's class names are not a stable API, so check the theme after upgrading Swashbuckle.
The OpenAPI document is served as OpenAPI 3.2 by default; set SwaggerOptions.OpenApiVersion with services.Configure<SwaggerOptions>(...) to serve another version.
See the package catalog and toolkit overview.
Third-party dependencies
This package brings these libraries, which its name does not announce:
| Library | Why | In the public API? |
|---|---|---|
| Swashbuckle.AspNetCore | Generates the OpenAPI document and serves Swagger UI | Yes: the operation filters implement its IOperationFilter; SwaggerOptions sets the OpenAPI version |
| Microsoft.OpenApi | The OpenAPI document model | Yes: the filters take OpenApiOperation |
Releases
See the release notes for the complete release history.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Anarchy.Toolkit.Runtime.Web (>= 1.0.0)
- Humanizer (>= 3.0.10)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.15)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 10.0.15)
- Microsoft.Extensions.Hosting.Systemd (>= 10.0.15)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.23.0)
- Microsoft.OpenApi (>= 3.11.1)
- Newtonsoft.Json (>= 13.0.4)
- Swashbuckle.AspNetCore (>= 11.0.1)
- System.IdentityModel.Tokens.Jwt (>= 8.23.0)
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.0 | 48 | 11/27/2026 |
## Releases
### 1.0.0
- Introduced the package with the Swagger/OpenAPI generation, Swagger UI and theme extracted from `Anarchy.Toolkit.Runtime.Web`.