Conversation
Renormalize some line-endings.
- Do not compress files if the internal compression is worse (e.g. swagger-ui `.png` files). - Fix over aggressive matching for `gzip`. - Remove some redundant operations. - Remove redundant null checks. - Use cancellation token when serving resource files. - Exclude `.txt` files from embedded swagger-ui resources. - Extend GZip integration tests for ReDoc and swagger-ui. - Code style changes.
Rename `CompressedEmbeddedFileResponder` to `EmbeddedResourceProvider` as the compression is an implementation detail as far as the caller is concerned.
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3480 +/- ##
==========================================
+ Coverage 93.88% 93.91% +0.02%
==========================================
Files 111 110 -1
Lines 3795 3810 +15
Branches 723 723
==========================================
+ Hits 3563 3578 +15
Misses 232 232
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the embedded GZip compression pipeline for Swagger UI and ReDoc, replacing custom responders with a unified EmbeddedResourceProvider, tightening gzip matching logic, and improving test coverage with parameterized tests.
- Introduce
EmbeddedResourceProviderand removeCompressedEmbeddedFileResponderand related extensions - Update integration tests to use
TheoryData, member data, cancellation tokens, and exclude.txtfiles - Adjust project files to embed compressed resources and exclude
.txtassets
Reviewed Changes
Copilot reviewed 10 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs | Parameterize asset tests, add decompressed and compressed scenarios |
| test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs | Separate decompressed and compressed asset tests for ReDoc |
| src/Swashbuckle.AspNetCore.SwaggerUI/Swashbuckle.AspNetCore.SwaggerUI.csproj | Swap in EmbeddedResourceProvider.cs; exclude .txt from embed |
| src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs | Use EmbeddedResourceProvider, pass cancellation tokens |
| src/Swashbuckle.AspNetCore.ReDoc/Swashbuckle.AspNetCore.ReDoc.csproj | Swap in EmbeddedResourceProvider.cs |
| src/Swashbuckle.AspNetCore.ReDoc/ReDocMiddleware.cs | Use EmbeddedResourceProvider, pass cancellation tokens |
| src/Shared/HttpContextAcceptEncodingCheckExtensions.cs | Removed (now handled in EmbeddedResourceProvider) |
| src/Shared/CompressedEmbeddedFileResponder.cs | Removed (replaced by EmbeddedResourceProvider) |
| src/Shared/EmbeddedResourceProvider.cs | New unified provider for embedded resources with gzip logic |
| exclusion.dic | Added GZip, JavaScript, OAuth entries |
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
Show resolved
Hide resolved
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
Show resolved
Hide resolved
- Apply Copilot refactoring suggestions from #3480. - Refactor repetitive use of `TestContext.Current.CancellationToken`.
- Apply Copilot refactoring suggestions from #3480. - Refactor repetitive use of `TestContext.Current.CancellationToken`.
.pngfiles).gzip..txtfiles from embedded swagger-ui resources.Follow-up to #3399.