Skip to content

Add MapSwaggerUI and MapReDoc to support endpoint routing#3822

Merged
martincostello merged 11 commits into
domaindrivendev:masterfrom
Strepto:map-for-swaggerui
Mar 26, 2026
Merged

Add MapSwaggerUI and MapReDoc to support endpoint routing#3822
martincostello merged 11 commits into
domaindrivendev:masterfrom
Strepto:map-for-swaggerui

Conversation

@Strepto
Copy link
Copy Markdown
Contributor

@Strepto Strepto commented Mar 4, 2026

Pull Request

The issue or feature being addressed

Fixes #1726

Details on the issue fix or feature implementation

I tried following the API and making the change as small as possible. The biggest benefit of this change is to allow login protection of the Swagger endpoint via

app.MapSwaggerUI().RequireAuthorization();

Which allows us to secure the openapi spec and the swagger UI 👍

Remarks

I did not test if this works in other dotnet versions. I assume the CI tests will be able to check this for me.

@Strepto Strepto changed the title Add MapSwaggerUI support and related tests for endpoint routing Add MapSwaggerUI support for endpoint routing Mar 4, 2026
@Strepto Strepto marked this pull request as ready for review March 4, 2026 15:10
Comment thread docs/configure-and-customize-swaggerui.md Outdated
Comment thread docs/configure-and-customize-swaggerui.md Outdated
Comment thread docs/configure-and-customize-swaggerui.md Outdated
Comment thread src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs
Comment thread test/WebSites/WebApi.Map/Properties/launchSettings.json
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.05%. Comparing base (b03fdec) to head (3912023).
⚠️ Report is 44 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3822      +/-   ##
==========================================
+ Coverage   94.93%   95.05%   +0.12%     
==========================================
  Files         111      111              
  Lines        3886     3944      +58     
  Branches      784      795      +11     
==========================================
+ Hits         3689     3749      +60     
+ Misses        197      195       -2     
Flag Coverage Δ
Linux 95.05% <100.00%> (+0.12%) ⬆️
Windows 95.05% <100.00%> (+0.12%) ⬆️
macOS 95.05% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread docs/configure-and-customize-redoc.md Outdated
Comment thread docs/configure-and-customize-redoc.md Outdated
Comment thread docs/configure-and-customize-swaggerui.md Outdated
Comment thread src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs Outdated
Comment thread src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs Outdated
Comment thread test/WebSites/WebApi.Map/Program.cs Outdated
Comment thread test/WebSites/WebApi.Map/Program.cs Outdated
Comment thread test/WebSites/WebApi.Map/Program.cs Outdated
Comment thread test/WebSites/WebApi.Map/Program.cs Outdated
Strepto and others added 2 commits March 11, 2026 14:17
Co-authored-by: Martin Costello <martin@martincostello.com>
Comment thread src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs
@martincostello
Copy link
Copy Markdown
Collaborator

Can you re-run dotnet mdsnippets and commit the result please?

@Strepto Strepto changed the title Add MapSwaggerUI support for endpoint routing Add MapSwaggerUI and MapReDoc to support endpoint routing Mar 12, 2026
Comment thread src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs Outdated
Comment thread src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs
Comment thread src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs Outdated
Comment thread test/WebSites/WebApi.Map/Program.cs Outdated
Co-authored-by: Martin Costello <martin@martincostello.com>
Comment thread src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs
Comment thread src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs
Comment thread src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs
@martincostello martincostello enabled auto-merge (squash) March 26, 2026 13:55
@martincostello martincostello merged commit 1e43cbe into domaindrivendev:master Mar 26, 2026
13 checks passed
@martincostello martincostello added this to the v10.2.0 milestone Mar 26, 2026
martincostello added a commit that referenced this pull request Mar 26, 2026
- Bump version to 10.2.0.
- Fix-up some formatting from #3822.
- Add an extra integration test.
martincostello added a commit that referenced this pull request Mar 26, 2026
- Bump version to 10.2.0.
- Fix-up some formatting from #3822.
- Add an extra integration test.
This was referenced Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MapSwaggerUI extension method for IEndpointRouteBuilder

2 participants