Swagger Dark Theme
Learn how to switch your Swagger documentation to a sleek dark theme with a step-by-step guide for .NET Core and FastEndpoints projects.
This will be a short one.
So, if you are using Swagger with your project (for our example we will be using .NET Core), you might want to use the SwaggerUI with Dark Theme, since the default one can blind you.
Quick and easy way of doing this is adding this piece of css code that can be found here: SwaggerDark.css on GitHub
Big shoutout to the original blog post: Turn Swagger Theme to the Dark Mode - DEV Community
If you are using the standard Controller from the .NET Core Web Api, you just need to enable support for static files in the Configure method:
app.UseStaticFiles();
On the other hand, if you are using Fast Endpoints, you can simply do:
application.UseSwaggerUi(config => config.TransformToExternalPath = (internalUiRoute, request) =>
{
config.CustomInlineStyles = swaggerDark;
return internalUiRoute;
});
Where swaggerDark variable is the css copied from the website that I supplied, specifically this: SwaggerDark.css on GitHub
Happy Coding!
Related Posts
Azure DevOps Deployment Best Practices for .NET and .NET Core Applications
Learn essential Azure DevOps deployment best practices for .NET and .NET Core applications, including build pipelines, release pipelines, automated testing, and configuration management.
Duende IdentityServer: OpenID Connect and OAuth 2.0 for .NET
An introduction to Duende IdentityServer, the enterprise-grade framework for implementing OpenID Connect and OAuth 2.0 in .NET applications, covering key concepts like tokens, clients, and authentication flows.
The N+1 Query Problem in EF Core: Benchmarking Every Fix on PostgreSQL
Actual BenchmarkDotNet numbers for N+1 vs Include, split queries, projections, and compiled queries in EF Core 10 on PostgreSQL 16.