SwaggerWithSwagg 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package SwaggerWithSwagg --version 1.0.3
                    
NuGet\Install-Package SwaggerWithSwagg -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SwaggerWithSwagg" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SwaggerWithSwagg" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="SwaggerWithSwagg" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SwaggerWithSwagg --version 1.0.3
                    
#r "nuget: SwaggerWithSwagg, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SwaggerWithSwagg@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SwaggerWithSwagg&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=SwaggerWithSwagg&version=1.0.3
                    
Install as a Cake Tool

SwaggerWithSwagg

SwaggerWithSwagg is an enhanced Swagger UI library for ASP.NET Core that provides a modern, Postman-like interface for testing and documenting your APIs.

SwaggerWithSwagg Banner

✨ Features

  • 🎨 Modern Postman-like Interface - Clean, organized sidebar with endpoint collections
  • 🔐 Authorization Management - Support for Bearer tokens, API keys, OAuth2
  • 🚀 Try It Out Panel - Execute API requests with automatic request/response caching
  • 📁 File Upload Support - Single, multiple, and file with metadata uploads
  • 🔄 API Versioning - Support for multiple API versions with easy switching
  • 🌙 Dark/Light Theme - Toggle between themes with persistent preference
  • 📊 cURL Generation - Automatic cURL command generation for all requests

📦 Installation

dotnet add package SwaggerWithSwagg

Framework Support:

  • .NET 6.0
  • .NET 7.0
  • .NET 8.0
  • .NET 9.0

🚀 Usage

Single API Version

using SwaggerWithSwagg;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

builder.Services.AddSwaggerGen(c =>
{
    // Configure SwaggerGen with all recommended settings for SwaggerWithSwagg
    c.ConfigureForSwaggerWithSwagg();
    
    // Add common operation filters (AllowAnonymous and single content-type)
    c.AddSwaggerWithSwaggFilters();
});

var app = builder.Build();

app.UseSwagger();
app.UseSwaggerWithSwagg(options =>
{
    options.DocumentTitle = "Sample API - Enhanced Documentation";
    options.SwaggerEndpoint = "../swagger/v1/swagger.json";
    options.RoutePrefix = "swagger";
});

app.UseAuthorization();
app.MapControllers();

app.Run();

Access your API documentation at: http://localhost:<port>/swagger


Multiple API Versions

using SwaggerWithSwagg;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

builder.Services.AddSwaggerGen(c =>
{
    // Configure SwaggerGen with all recommended settings for SwaggerWithSwagg
    c.ConfigureForSwaggerWithSwagg();
    
    // Add common operation filters (AllowAnonymous and single content-type)
    c.AddSwaggerWithSwaggFilters();
    
    // Define v1 API
    c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
    {
        Title = "Sample API",
        Version = "v1",
        Description = "Version 1 of the Sample API with basic endpoints",
        Contact = new Microsoft.OpenApi.Models.OpenApiContact
        {
            Name = "API Team",
            Email = "api@example.com"
        }
    });

    // Define v2 API
    c.SwaggerDoc("v2", new Microsoft.OpenApi.Models.OpenApiInfo
    {
        Title = "Sample API",
        Version = "v2",
        Description = "Version 2 of the Sample API with enhanced features",
        Contact = new Microsoft.OpenApi.Models.OpenApiContact
        {
            Name = "API Team",
            Email = "api@example.com"
        }
    });
   
    // Configure version filtering
    c.DocInclusionPredicate((docName, apiDesc) =>
    {
        var actionDescriptor = apiDesc.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;
        if (actionDescriptor == null) return false;

        var apiVersion = actionDescriptor.ControllerTypeInfo
            .GetCustomAttributes(typeof(ApiVersionAttribute), true)
            .Cast<ApiVersionAttribute>()
            .FirstOrDefault();

        if (apiVersion == null) return docName == "v1"; // Default to v1

        var version = apiVersion.Version;
        
        // Each version shows only its own endpoints
        return docName == version;
    });
});

var app = builder.Build();

app.UseSwagger();
app.UseSwaggerWithSwagg(options =>
{
    options.DocumentTitle = "Sample API - Enhanced Documentation";
    options.ApiVersions = new List<SwaggerVersion>
    {
        new SwaggerVersion { Name = "v1 - Stable", Endpoint = "/swagger/v1/swagger.json", Description = "Production-ready v1 endpoints" },
        new SwaggerVersion { Name = "v2 - Enhanced", Endpoint = "/swagger/v2/swagger.json", Description = "v2 with enhanced features" }
    };
});

app.UseAuthorization();
app.MapControllers();

app.Run();

// Custom attribute for API versioning
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class ApiVersionAttribute : Attribute
{
    public string Version { get; }
    public ApiVersionAttribute(string version)
    {
        Version = version;
    }
}

Apply versioning to your controllers:

[ApiController]
[Route("api/[controller]")]
[ApiVersion("v1")]
public class ProductsController : ControllerBase
{
    [HttpGet]
    public IActionResult GetProducts()
    {
        return Ok(new[] { "Product A", "Product B" });
    }
}

[ApiController]
[Route("api/[controller]")]
[ApiVersion("v2")]
public class ProductsV2Controller : ControllerBase
{
    [HttpGet]
    public IActionResult GetProducts()
    {
        return Ok(new[] 
        { 
            new { id = 1, name = "Product A", price = 99.99 },
            new { id = 2, name = "Product B", price = 149.99 }
        });
    }
}

📖 Example

Check out the included SampleApi project for a complete working example.

Run the sample:

cd SampleApi
dotnet run

Navigate to http://localhost:5293/swagger to see SwaggerWithSwagg in action.


� Appendix - Screenshots

Main Interface

SwaggerWithSwagg Main Interface

API Version Selector

API Version Selector

Try It Out Panel

Try It Out Panel

Request Execution

Request Execution

Response Display

Response Display


�📝 License

MIT License


🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 135 2/11/2026
1.0.8 322 11/1/2025
1.0.7 290 10/24/2025
1.0.6 260 10/22/2025
1.0.5 289 10/22/2025
1.0.4 217 10/22/2025
1.0.3 218 10/22/2025
1.0.2 218 10/22/2025
1.0.1 224 10/22/2025
1.0.0 220 10/22/2025