Modernize your ASP.NET Core Swagger UI with runtime theme switching, deep customization, and new functional UI features.
$ dotnet add package AspNetCore.SwaggerUI.ThemesWarning: Starting from v1.0.0 the namespace for pre-defined styles is
AspNetCore.Swagger.Themesinstead ofAspNetCore.SwaggerUI.Themes!
AspNetCore.SwaggerUI.Themes builds upon Swashbuckle.AspNetCore.SwaggerUI, enhancing the Swagger UI with modern and visually appealing themes.
Customize the Swashbuckle API documentation UI by using AspNetCore.SwaggerUI.Themes in your ASP.NET Core project:
Install the package using .NET CLI or NuGet Package Manager:
dotnet add package AspNetCore.SwaggerUI.Themes
or
Install-Package AspNetCore.SwaggerUI.Themes
In your Program.cs file, add the style through the Style, ModernStyle or NoJsModernStyle class as new parameter of app.UseSwaggerUI() method:
using AspNetCore.Swagger.Themes;
...
app.UseSwaggerUI(ModernStyle.Dark, options => ...);
This code enables the chosen theme for Swagger UI in your application.
[!NOTE] Using the
InjectStylesheet()method in the Swagger UI configuration will override the provided style. See here how to inject custom styles.
See here the available themes.