Skip to content

Migration v2

teociaps edited this page Nov 27, 2025 · 2 revisions

Migration Guide: v1.x → v2.0

This guide helps you migrate from SwaggerUI.Themes v1.x to v2.0.

Breaking Changes

Removal of NoJsModernStyle

What Changed:

The NoJsModernStyle class has been deprecated and removed. Its functionality has been merged into ModernStyle.

Why:

  • Simplified API - one less class to remember
  • More flexible - features are opt-in via advanced options
  • Better defaults - JavaScript features disabled by default

Migration Steps

Step 1: Replace NoJsModernStyle with ModernStyle

// ❌ Before (v1.x)
app.UseSwaggerUI(NoJsModernStyle.Dark);

// ✅ After (v2.0)
app.UseSwaggerUI(ModernStyle.Dark);

Step 2: Enable JavaScript Features (if needed)

If you want JavaScript features, enable them explicitly:

// ✅ v2.0 - Enable features as needed
app.UseSwaggerUI(ModernStyle.Dark, options =>
{
    options.EnablePinnableTopbar();
    options.ShowBackToTopButton();
    options.EnableStickyOperations();
    options.EnableExpandOrCollapseAllOperations();
    
    // Or enable all at once:
    // options.EnableAllAdvancedOptions();
});

Default Behavior Change

Class v1.x Behavior v2.0 Behavior
ModernStyle ✅ JavaScript enabled ❌ JavaScript disabled (opt-in)
NoJsModernStyle ❌ JavaScript disabled ⛔ Removed - use ModernStyle

Note

In v2.0, ModernStyle defaults to no JavaScript unless you explicitly enable features.

Migration Checklist

  • Find all uses of NoJsModernStyle
  • Replace with ModernStyle
  • If you need JavaScript features, enable them via options
  • Test your application
  • Verify themes render correctly

Complete Example

Before (v1.x)

using AspNetCore.Swagger.Themes;

// Without JavaScript
app.UseSwaggerUI(NoJsModernStyle.Dark);

// With JavaScript
app.UseSwaggerUI(ModernStyle.Dark);

After (v2.0)

using AspNetCore.Swagger.Themes;

// Without JavaScript (same as v1.x NoJsModernStyle)
app.UseSwaggerUI(ModernStyle.Dark);

// With JavaScript (explicitly enabled)
app.UseSwaggerUI(ModernStyle.Dark, options =>
{
    options.EnableAllAdvancedOptions();
});

Need Help?

Upgrading to v3.0?

If you're migrating from v1.x directly to v3.0, you'll also need to apply the v3.0 changes:

See v3.0 Migration Guide

The v3.0 changes include:

  • ModernStyleTheme rename
  • Additional new features

Migration complete! Your application is now running v2.0. ✅

Clone this wiki locally