Thank you for considering contributing to SwaggerUI.Themes! We welcome contributions from the community to help improve and grow the project.
This project and everyone participating in it are governed by our Code of Conduct.
-
Fork the repository to your GitHub account.
-
Clone the forked repository to your local machine.
-
Create a new branch for your contribution:
git checkout -b feature/my-feature
-
Make your changes and commit them:
git commit -m "Add new feature" -
Push the changes to your fork:
git push origin feature/my-feature
-
Open a pull request (PR) against the main branch of the original repository.
Understanding the project layout helps you navigate the codebase:
src/AspNetCore.Swagger.Themes.Common/- Core theme system shared between packagessrc/AspNetCore.SwaggerUI.Themes/- Swashbuckle.AspNetCore integrationsrc/NSwag.AspNetCore.Themes/- NSwag.AspNetCore integrationsamples/- Example applications demonstrating usagetests/- Unit and integration tests
Themes are defined as CSS files with optional JavaScript for advanced features. When working with themes:
- Original files - Make your changes in the non-minified
.cssor.jsfiles - Minified versions - Must be manually updated (see Minification Process below)
- Headers - Minified files require specific comment headers for testing
The project uses minified versions at runtime for performance. After editing CSS or JavaScript:
- Navigate to CSS Minifier
- Copy the entire content of your modified CSS file
- Paste into the minifier and click "Minify"
- Copy the minified output
- Add the compact header at the very beginning (format below)
- Paste into the corresponding
.min.cssfile - Verify placeholders are preserved (e.g.,
#STICKY_OPERATIONSincommon.css)
- Navigate to JavaScript Minifier
- Copy the entire content of your modified JavaScript file
- Paste into the minifier and click "Minify"
- Copy the minified output
- Add the compact header at the very beginning (format below)
- Paste into the corresponding
.min.jsfile - Verify all placeholders are preserved:
{$PINNABLE_TOPBAR}{$BACK_TO_TOP}{$EXPAND_COLLAPSE_ALL_OPERATIONS}{$THEME_SWITCHER}
All minified files must start with this compact comment:
/*Name*/[minified content]
Examples:
dark.min.css→/*Dark Theme*/body{...common.min.css→/*Common*/body{...ui.min.js→/*Swagger UI*/const ...
Why? Tests verify headers are present and correctly formatted. This ensures minification was done properly.
Placeholders like {$THEME_SWITCHER} are replaced at runtime based on user settings. Minification must preserve these exact strings, or features will break.
Always commit both original and minified versions:
git add src/AspNetCore.Swagger.Themes.Common/AspNetCore/Swagger/Themes/Styles/*.css
git add src/AspNetCore.Swagger.Themes.Common/AspNetCore/Swagger/Themes/Scripts/*.js
git commit -m "Add new ocean theme"Before submitting a pull request:
dotnet build -c ReleaseEnsure there are no compilation errors.
dotnet testAll tests must pass, including:
- Minified header format tests
- Theme discovery tests
- Integration tests
Run both sample projects to verify functionality:
# Swashbuckle sample
dotnet run --project samples/Sample.AspNetCore.SwaggerUI.Swashbuckle
# NSwag sample
dotnet run --project samples/Sample.AspNetCore.SwaggerUI.NSwagOpen the sample app in your browser and verify:
- ✅ Themes render correctly
- ✅ Theme switcher dropdown appears and works (if enabled)
- ✅ Custom themes are discovered automatically
- ✅ Advanced features work (pinnable topbar, back-to-top, etc.)
- ✅ No console errors in browser developer tools
- ✅ Standalone themes load without extra dependencies
- Follow existing code style - Match the patterns you see in the codebase
- Include tests - Add or update tests for your changes
- Update documentation - If adding features, update relevant docs
- Keep PRs focused - One feature or fix per PR (submit separate PRs for multiple changes)
- Provide context - Explain why the change is needed, not just what changed
- Be responsive - Address feedback and questions promptly
- Use descriptive titles:
feat: add sunset themenotupdate css - Reference issues:
Fixes #123orCloses #456 - Include screenshots for visual changes
- Test across .NET 8, 9, and 10 if possible
Found a bug? Please open an issue with:
- Clear description of the problem
- Steps to reproduce the issue
- Expected vs. actual behavior
- Environment details:
- Which package (Swashbuckle or NSwag)
- .NET version
- Browser (if UI-related)
- Screenshots or code snippets if applicable
We welcome feature suggestions! When proposing a feature:
- Describe the use case - What problem does it solve?
- Explain the benefit - How does it improve the project?
- Consider backward compatibility - Will it break existing code?
- Offer to help - Can you contribute the implementation?
For rapid iteration during development:
- Make your changes
- Build:
dotnet build - Run sample:
dotnet run --project samples/Sample.AspNetCore.SwaggerUI.Swashbuckle - Refresh browser (F5) (clear the browser cache if necessary) to see changes
When adding example custom themes, use subfolders for clarity:
samples/YourSample/SwaggerThemes/
├── CompanyThemes/
│ └── corporate-blue.css
└── SeasonalThemes/
└── holiday-red.css
This demonstrates best practices for users organizing their own themes.
- Regular themes - Depend on
common.cssand may use JavaScript features - Standalone themes - Prefix with
standalone.(e.g.,standalone.custom.css) for zero dependencies
Choose based on whether you need shared styles or prefer total independence.
Not sure about something? Feel free to:
- Open an issue for clarification
- Ask in your pull request
- Reference existing code patterns
By contributing, you agree that your contributions will be licensed under the same MIT License that covers the project.
Thank you for making SwaggerUI.Themes better! 🎨