Repository navigation
Use IAsyncSwaggerProvider in CLI tofile command - #3910
Merged
martincostello merged 1 commit intoApr 21, 2026
Merged
Conversation
Contributor
Author
|
The issue #1661 appears to have missed the CLI implementation of Swagger. So async filters registered in the application are not called. Happy to adjust based on feedback, but would love to be able to use async policy filters with swagger cli. |
bt-Knodel
force-pushed
the
cli-async-swagger-provider
branch
from
April 19, 2026 12:56
71ba7a1 to
2271ae2
Compare
martincostello
left a comment
Collaborator
There was a problem hiding this comment.
Just a few small style nits.
bt-Knodel
force-pushed
the
cli-async-swagger-provider
branch
from
April 20, 2026 20:23
2271ae2 to
514c304
Compare
martincostello
approved these changes
Apr 21, 2026
Collaborator
|
Looks like some tests need fixing. |
Co-Authored-By: Claude Opus 4.6
bt-Knodel
force-pushed
the
cli-async-swagger-provider
branch
from
April 21, 2026 15:31
514c304 to
034e1e3
Compare
Contributor
Author
|
Added the missing Kiota files to fix the test. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3910 +/- ##
=======================================
Coverage 95.04% 95.04%
=======================================
Files 111 111
Lines 3958 3958
Branches 801 801
=======================================
Hits 3762 3762
Misses 196 196
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:
|
martincostello
merged commit Apr 21, 2026
4a2efa3
into
domaindrivendev:master
18 of 19 checks passed
This was referenced May 30, 2026
Bump Swashbuckle.AspNetCore from 5.6.3 to 10.2.0
gabrielstramontin/secure-repository-supply-chain#11
Closed
This was referenced Oct 6, 2026
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The CLI's
tofilecommand resolvesISwaggerProviderand calls the synchronousGetSwagger(), which internally usesGenerateOperation(). This sync path only invokesIOperationFilterregistrations —IOperationAsyncFilterregistrations are silently skipped.This means any project using
OperationAsyncFilter() gets correct output from the runtime swagger middleware but missing output fromdotnet swagger tofile, leading to inconsistencies in generated clients (e.g., via Orval/NSwag).Changes
CommandRunnerandProgram.Mainfully async — no sync-over-async (GetAwaiter().GetResult())_tofilecommand prefersIAsyncSwaggerProvider.GetSwaggerAsync()when available, falling back toISwaggerProvider.GetSwagger()for backward compatibilityAuthorizationtest WebSite demonstrating real-world async filter:SecurityRequirementsAsyncOperationFilterresolves authorization policies viaIAuthorizationPolicyProvider.GetPolicyAsync()and adds security requirements to operationsTest plan
Can_Generate_Swagger_Json_With_Async_Operation_Filterstest verifies async filter output via CLIAuthorizationWebSite validates real-world use case: async operation filter resolves authorization policies viaIAuthorizationPolicyProvider.GetPolicyAsync()and documents security requirements on protected endpoints