Skip to content

Conversation

@martincostello
Copy link
Collaborator

- Add a custom header that returns the Redoc/swagger-ui version.
- Make parameter non-optional.
Do not respond with gzip if the quality is zero.
@martincostello martincostello added this to the v9.0.4 milestone Jul 9, 2025
Copilot AI review requested due to automatic review settings July 9, 2025 07:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances how Accept-Encoding quality values are handled—specifically preventing gzip when its quality is zero—and exposes the Swagger UI and ReDoc versions via custom response headers.

  • Skip gzip encoding when its quality is explicitly set to zero.
  • Add x-swagger-ui-version and x-redoc-version headers to responses.
  • Convert a ReDoc middleware test to a parameterized theory covering various Accept-Encoding scenarios.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs Converted the test to a [Theory] with multiple Accept-Encoding inputs and built a custom request message.
src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs Renamed cache-header method, added Swagger UI version header, and updated ETag handling.
src/Swashbuckle.AspNetCore.ReDoc/ReDocMiddleware.cs Renamed cache-header method, added ReDoc version header, and updated ETag handling.
src/Shared/EmbeddedResourceProvider.cs Updated IsGZipAccepted to check the Quality property before accepting gzip.
Comments suppressed due to low confidence (2)

test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs:206

  • The test only asserts the status code but does not verify that the response content was correctly decompressed or matches the expected asset. Consider adding assertions to validate the response body against the original uncompressed asset.
        Assert.Equal(HttpStatusCode.OK, response.StatusCode);

test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs:197

  • The empty array literal '[]' is not valid C# syntax for an empty enumerable. Consider replacing 'encodings ?? []' with 'encodings ?? Array.Empty()' to ensure compilation and clarity.
        foreach (var encoding in encodings ?? [])

@codecov
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.28%. Comparing base (3bff9ad) to head (c1c877b).
Report is 2 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3493      +/-   ##
==========================================
+ Coverage   93.88%   94.28%   +0.39%     
==========================================
  Files         110      110              
  Lines        3812     3816       +4     
  Branches      724      722       -2     
==========================================
+ Hits         3579     3598      +19     
+ Misses        233      218      -15     
Flag Coverage Δ
Linux 94.28% <100.00%> (+0.39%) ⬆️
Windows 94.28% <100.00%> (+0.39%) ⬆️
macOS 94.28% <100.00%> (+0.39%) ⬆️

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.

@martincostello martincostello merged commit 6aa4666 into master Jul 9, 2025
12 checks passed
@martincostello martincostello deleted the check-quality branch July 9, 2025 07:46
This was referenced Aug 27, 2025
This was referenced Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants