Skip to content

teociaps/SwaggerUI.Themes

Repository files navigation

SwaggerUI.Themes

Build Passing Tests Passing NuGet Version

AspNetCore.SwaggerUI.Themes is a package that extends Swashbuckle.AspNetCore.SwaggerUI to provide new themes for Swagger documentation in ASP.NET Core applications.

Introduction

Swashbuckle.AspNetCore is a popular library for adding Swagger support to ASP.NET Core projects, making it easier to document and interact with your APIs.

AspNetCore.SwaggerUI.Themes builds upon Swashbuckle.AspNetCore.SwaggerUI, enhancing the Swagger UI with modern and visually appealing themes.

Features

  • New Themes: enhances the Swagger documentation interface with various themes, including a default style that preserves the classic Swagger UI appearance and introduces new modern styles. Explore samples here.
  • Seamless Integration: simply install the package and add the style parameter to the existing method used for SwaggerUI.

Note

Modern styles come with additional functionalities, including pinned topbar and back-to-top button.

Supported .NET Versions

Version Status
.NET 6 Badge
.NET 7 Badge
.NET 8 Badge

Version History

The table below provides a quick overview of AspNetCore.SwaggerUI.Themes versions and their compatibility with different .NET versions.

Library Version .NET 6 .NET 7 .NET 8
0.1.0
0.2.0 +
  • ✔️ Supported: The library version is compatible with the respective .NET version.
  • ❌ Unsupported: The library version is not compatible with the respective .NET version.

Getting Started

To use AspNetCore.SwaggerUI.Themes in your ASP.NET Core project, follow these steps:

  1. Install the package using .NET CLI or NuGet Package Manager:

    dotnet add package AspNetCore.SwaggerUI.Themes

    or

    Install-Package AspNetCore.SwaggerUI.Themes
  2. In your Program.cs file, add the style through the Style or ModernStyle class as new parameter of app.UseSwaggerUI() method:

    using AspNetCore.SwaggerUI.Themes;
    
    ...
    
    app.UseSwaggerUI(Style.Dark);

    This code enables the chosen theme for Swagger UI in your application.

Important

Please be aware that for projects utilizing the older style template with separate Startup.cs and Program.cs files, the previously code should be configured within the Configure method of the Startup class.

Example

Here's an example of how to integrate AspNetCore.SwaggerUI.Themes in your ASP.NET Core application:

using AspNetCore.SwaggerUI.Themes;
...

// Add services to the container. Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

...

// Use Swagger middleware
app.UseSwagger();

// Enable the dark theme for Swagger UI
app.UseSwaggerUI(ModernStyle.Dark, c =>
{
    // Your Swagger UI configuration here (optional)
});

...

That's it! Your Swagger UI will now have a sleek dark theme.

Note

Using the InjectStylesheet() method in the Swagger UI configuration will override the provided style.

Contributing

If you have any suggestions, bug reports, or contributions, feel free to open an issue or submit a pull request

About

An extension library which enhances Swagger middleware functionality, offering new themes for API documentation in ASP.NET Core applications.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published