-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added dependency injection/easy registration for async filters #3030
Added dependency injection/easy registration for async filters #3030
Conversation
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptions.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
Outdated
Show resolved
Hide resolved
test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSwaggerGeneratorOptionsTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Costello <martin@martincostello.com>
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
Show resolved
Hide resolved
I was very say today when I converted a bunch of filters to be async and then couldn't register them without a bunch of ceremony. I definitely would like this to make it in in some form! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3030 +/- ##
==========================================
+ Coverage 90.18% 90.43% +0.24%
==========================================
Files 74 74
Lines 2964 3041 +77
Branches 463 487 +24
==========================================
+ Hits 2673 2750 +77
Misses 291 291
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks for your contribution - this looks good. Could you bump the version to 6.8.0 as we're adding new public API members please? Then this looks good to merge.
|
Hi @martincostello Thanks for your input and for accepting :) |
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [Swashbuckle.AspNetCore](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore) | `6.7.3` -> `6.8.0` | [![age](https://developer.mend.io/api/mc/badges/age/nuget/Swashbuckle.AspNetCore/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/Swashbuckle.AspNetCore/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/Swashbuckle.AspNetCore/6.7.3/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Swashbuckle.AspNetCore/6.7.3/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>domaindrivendev/Swashbuckle.AspNetCore (Swashbuckle.AspNetCore)</summary> ### [`v6.8.0`](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/releases/tag/v6.8.0) ##### What's Changed - Added dependency injection/easy registration for async filters by [@​tofi92](https://redirect.github.com/tofi92) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3030](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3030) - Improve IncludeXmlComments performance (2) by [@​mus65](https://redirect.github.com/mus65) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3044](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3044) - Apply ParameterFilters and RequestBodyFilters for WithOpenApi endpoints by [@​jgarciadelanoceda](https://redirect.github.com/jgarciadelanoceda) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3059](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3059) - Swagger plugins support by [@​jvmlet](https://redirect.github.com/jvmlet) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3056](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3056) - Add benchmarks project by [@​martincostello](https://redirect.github.com/martincostello) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3050](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3050) - Fix NuGet badge by [@​martincostello](https://redirect.github.com/martincostello) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3064](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3064) - SwaggerGen - Improved handling of dictionaries with enum key by [@​flarestudiopl](https://redirect.github.com/flarestudiopl) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3068](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3068) - Fix typo by [@​tom-star119](https://redirect.github.com/tom-star119) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3073](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3073) - Do not fill the RequestBody description with the first parameter of a… by [@​jgarciadelanoceda](https://redirect.github.com/jgarciadelanoceda) in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3076](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3076) ##### New Contributors - [@​tofi92](https://redirect.github.com/tofi92) made their first contribution in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3030](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3030) - [@​mus65](https://redirect.github.com/mus65) made their first contribution in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3044](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3044) - [@​jvmlet](https://redirect.github.com/jvmlet) made their first contribution in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3056](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3056) - [@​flarestudiopl](https://redirect.github.com/flarestudiopl) made their first contribution in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3068](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3068) - [@​tom-star119](https://redirect.github.com/tom-star119) made their first contribution in [https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3073](https://redirect.github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/3073) **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v6.7.3...v6.8.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 10pm every weekday,every weekend,before 5am every weekday" in timezone Europe/Berlin, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/orso-co/Orso.Arpa.Api). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC45Ny4wIiwidXBkYXRlZEluVmVyIjoiMzguOTcuMCIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AiLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Async filters (#2938) could not be registered with the SwaggerGenOptions, so there was no way of using DI with async filters.
I extended the SwaggerGenOptions for all the async filters and also added extension methods similiar to the sync equivalents, so added async filters is now as intuitive as sync filters, e.g.
swaggerGenOptions.DocumentAsyncFilter<MyAsyncFilter>()
.