Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This project and everyone participating in it are governed by our [Code of Condu

## Working with Styles and Scripts

When contributing changes to CSS or JavaScript files, please follow these guidelines to ensure both original and minified versions are properly maintained.
When contributing changes to CSS or JavaScript files for themes, please follow these guidelines to ensure both original and minified versions are properly maintained.

### Minification Process

Expand Down
146 changes: 114 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,146 @@
<span align="center">
<div align="center">

<p>
<img height="50" src="\build\icon.png" align="center">
<img height="80" src="build/icon.png" alt="SwaggerUI.Themes Logo">
</p>

# SwaggerUI.Themes

</span>

<p align="center">
<p>
<a href="https://github.com/teociaps/SwaggerUI.Themes/actions/workflows/build.yml">
<img alt="Build Passing" src="https://github.com/teociaps/SwaggerUI.Themes/actions/workflows/build.yml/badge.svg" />
<img alt="Build" src="https://github.com/teociaps/SwaggerUI.Themes/actions/workflows/build.yml/badge.svg" />
</a>
<a href="https://github.com/teociaps/SwaggerUI.Themes/actions/workflows/test.yml">
<img alt="Tests Passing" src="https://github.com/teociaps/SwaggerUI.Themes/actions/workflows/test.yml/badge.svg" />
<img alt="Tests" src="https://github.com/teociaps/SwaggerUI.Themes/actions/workflows/test.yml/badge.svg" />
</a>
</p>

<h4 align="center">Customize your API documentation in ASP.NET Core applications!</h4>
### Beautiful, modern themes for Swagger/OpenAPI documentation in ASP.NET Core

Make your API documentation look great with themes that fit your style.

**[Get Started](https://github.com/teociaps/SwaggerUI.Themes/wiki/Getting-Started)** • **[View Themes](https://github.com/teociaps/SwaggerUI.Themes/wiki/Predefined-Themes)** • **[Full Documentation](https://github.com/teociaps/SwaggerUI.Themes/wiki)**

---

| Package | Purpose | NuGet |
|---------|---------|-------|
| **AspNetCore.SwaggerUI.Themes** | For [Swashbuckle.AspNetCore][swashbuckle-link] | [![swashbuckle-nuget]][swashbuckle-nuget-link] |
| **NSwag.AspNetCore.Themes** | For [NSwag.AspNetCore][nswag-link] | [![nswag-nuget]][nswag-nuget-link] |

---

</div>

> [!WARNING]
> **Version 3.0.0 Breaking Changes**
>
> Upgrading from v2.0.0? Please review the **[Migration Guide](https://github.com/teociaps/SwaggerUI.Themes/wiki/Migration-v3)** for important API changes.


## 🚀 Quick Start

```bash
# Install package
dotnet add package AspNetCore.SwaggerUI.Themes
# or
dotnet add package NSwag.AspNetCore.Themes
```

```csharp
// Apply a theme - that's it!
app.UseSwaggerUI(Theme.Dark); // Swashbuckle
// or
app.UseSwaggerUi(Theme.Dark); // NSwag
```

## ✨ Features

- **[Built-in Themes](https://github.com/teociaps/SwaggerUI.Themes/wiki/Predefined-Themes)** - Choose from predefined themes ready to use

- **[Custom Themes](https://github.com/teociaps/SwaggerUI.Themes/wiki/Custom-Themes)** - Build your own themes with full control, or create standalone themes with zero dependencies

- **[Advanced Features](https://github.com/teociaps/SwaggerUI.Themes/wiki/Advanced-Options)** - Enhance your documentation with new capabilities

**Discover more in the [Wiki](https://github.com/teociaps/SwaggerUI.Themes/wiki)!**

## 💡 Basic Usage Examples

### Swashbuckle

```csharp
using AspNetCore.Swagger.Themes;

...

// Simple
app.UseSwaggerUI(Theme.Dark);

// Or with advanced options
app.UseSwaggerUI(Theme.Dark, c =>
{
c.EnableAllAdvancedOptions();
});

...
```

<table align="center">
<tr>
<td>
Explore the <b><a href="https://github.com/teociaps/SwaggerUI.Themes/wiki" title="Wiki">Wiki</a></b> to learn more and <b><a href="https://github.com/teociaps/SwaggerUI.Themes/wiki/Getting-Started" title="Getting Started">get started</a></b>.
</td>
</tr>
</table>
### NSwag

```csharp
using AspNetCore.Swagger.Themes;

<hr>
...

// Simple
app.UseSwaggerUi(Theme.Dark);

| Package | Purpose |
| :------ | :------ |
| [![Swashbuckle Nuget Version]](https://www.nuget.org/packages/AspNetCore.SwaggerUI.Themes/) | Customize the style for [Swashbuckle.AspNetCore.SwaggerUI] |
| [![NSwag Nuget Version]](https://www.nuget.org/packages/NSwag.AspNetCore.Themes/) | Customize the style for [NSwag.AspNetCore] |
// Or with advanced options
app.UseSwaggerUi(Theme.Dark, c =>
{
c.EnableAllAdvancedOptions();
});

...
```

## Features
### Custom Theme

- **[Predefined Themes](https://github.com/teociaps/SwaggerUI.Themes/wiki/Predefined-Themes)**: choose from a variety of themes to customize the Swagger documentation interface. Options include a default style that preserves the classic Swagger UI look, along with fresh, modern styles.
```csharp
public class MyTheme : Theme
{
protected MyTheme() : base("my-theme.css") { }
public static MyTheme Custom => new();
}

- **[Custom Styles](https://github.com/teociaps/SwaggerUI.Themes/wiki/Custom-Styles)**: design your own Swagger UI style by either extending the classic or modern base styles or creating a completely new look.
// Usage
app.UseSwaggerUI(MyTheme.Custom); // Swashbuckle

- **[Advanced Options](https://github.com/teociaps/SwaggerUI.Themes/wiki/Advanced-Options)**: access expanded features with both classic and modern styles for an optimized API documentation experience.
app.UseSwaggerUi(MyTheme.Custom); // NSwag
```

**Learn more in the [Wiki](https://github.com/teociaps/SwaggerUI.Themes/wiki)!**

## Contributing
## 🤝 Contributing

If you have any suggestions, bug reports, or contributions, feel free to open an [issue](https://github.com/teociaps/SwaggerUI.Themes/issues) or submit a [pull request](https://github.com/teociaps/SwaggerUI.Themes/pulls).
Contributions are welcome! See the [Contributing Guide](CONTRIBUTING.md) for details.

## 📜 License

## Release
MIT Licensed - see [LICENSE](LICENSE) for details.

See the [release notes](https://github.com/teociaps/SwaggerUI.Themes/releases) for details.
---

<div align="center">

**Made with ❤️ by [@teociaps](https://github.com/teociaps)**

[Swashbuckle Nuget Version]: https://img.shields.io/nuget/v/AspNetCore.SwaggerUI.Themes?logo=nuget&label=AspNetCore.SwaggerUI.Themes&color=blue
[NSwag Nuget Version]: https://img.shields.io/nuget/v/NSwag.AspNetCore.Themes?logo=nuget&label=NSwag.AspNetCore.Themes&color=blue
</div>

[Swashbuckle.AspNetCore.SwaggerUI]: https://github.com/domaindrivendev/Swashbuckle.AspNetCore
[NSwag.AspNetCore]: https://github.com/RicoSuter/NSwag?tab=readme-ov-file#aspnet-and-aspnet-core
<!-- Links -->
[swashbuckle-nuget]: https://img.shields.io/nuget/v/AspNetCore.SwaggerUI.Themes?logo=nuget&label=Version&color=blue
[swashbuckle-nuget-link]: https://www.nuget.org/packages/AspNetCore.SwaggerUI.Themes/
[nswag-nuget]: https://img.shields.io/nuget/v/NSwag.AspNetCore.Themes?logo=nuget&label=Version&color=blue
[nswag-nuget-link]: https://www.nuget.org/packages/NSwag.AspNetCore.Themes/
[swashbuckle-link]: https://github.com/domaindrivendev/Swashbuckle.AspNetCore
[nswag-link]: https://github.com/RicoSuter/NSwag
2 changes: 1 addition & 1 deletion build/NuGet.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="LICENSE" />
<None Include="..\..\package-readme.md" Pack="true" PackagePath="\"/>
<None Include="package-readme.md" Pack="true" PackagePath="."/>
<None Include="readme.txt" pack="true" PackagePath="." />
</ItemGroup>

Expand Down
13 changes: 0 additions & 13 deletions package-readme.md

This file was deleted.

9 changes: 5 additions & 4 deletions samples/Sample.AspNetCore.SwaggerUI.NSwag/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Sample.AspNetCore.SwaggerUI.NSwag;
using SwaggerThemes;
using System.Reflection;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
Expand All @@ -16,9 +16,10 @@
//app.UseSwaggerUi(inlineStyle, c => c.DocumentTitle = "Sample Title");

//app.UseSwaggerUi(CustomMinifiedStyle.CustomMin, c =>
app.UseSwaggerUi(CustomModernStyle.CustomModern, c =>
//app.UseSwaggerUi(Assembly.GetExecutingAssembly(), "modern.custom.css", c =>
//app.UseSwaggerUi(ModernStyle.Dark, c =>
//app.UseSwaggerUi(CustomTheme.Custom, c =>
//app.UseSwaggerUi(Assembly.GetExecutingAssembly(), "custom.css", c =>
app.UseSwaggerUi(Assembly.GetExecutingAssembly(), "standalone.custom.css", c => // Fully independent - no common.css or ui.js
//app.UseSwaggerUi(Theme.Dark, c =>
{
c.DocumentTitle = "Sample Title";
c.EnableAllAdvancedOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
<OpenApiGeneratorDocumentsOnBuild>false</OpenApiGeneratorDocumentsOnBuild>
</PropertyGroup>

<ItemGroup>
<None Remove="SwaggerThemes\minifiedCustom.min.css" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NSwag.AspNetCore" Version="14.6.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0' ">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
</ItemGroup>
Expand All @@ -29,14 +21,14 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="SwaggerThemes\classic.custom.css" />
<EmbeddedResource Include="SwaggerThemes\custom.css" />
<EmbeddedResource Include="SwaggerThemes\minifiedCustom.min.css" />
<EmbeddedResource Include="SwaggerThemes\modern.custom.css" />
<EmbeddedResource Include="SwaggerThemes\standalone.custom.css" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NSwag.AspNetCore.Themes\NSwag.AspNetCore.Themes.csproj" />
<ProjectReference Include="..\..\src\AspNetCore.Swagger.Themes.Common\AspNetCore.Swagger.Themes.Common.csproj" />
</ItemGroup>

</Project>
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using AspNetCore.Swagger.Themes;

namespace SwaggerThemes;

public class CustomTheme : Theme
{
protected CustomTheme(string fileName) : base(fileName)
{
}

public static CustomTheme Custom => new("custom.css");
}

public class CustomMinifiedStyle : Theme
{
protected CustomMinifiedStyle(string fileName, bool useMinified) : base(fileName, useMinified)
{
}

public static CustomMinifiedStyle CustomMin => new("minifiedCustom.css", true);
}
Loading