Swashbuckle v4 and Scoped Dependency Injection.
See original GitHub issueScopedSwaggerMiddleware
is broken.
We need this library to work when scoped dependencies (ie DbContext
) are injected into AbstractValidators
(and other validator types). Preferably without using any workarounds.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to inject a scoped service in a Swashbuckle example ...
@grinay I already mentioned that it won't work due to how dependency injection works in middleware in ASP.NET Core. I updated the question...
Read more >Package needs update for Swashbuckle 4 · Issue #67
Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+<>c__DisplayClass1_0.b__0(ServiceProviderEngineScope scope)
Read more >Swagger tools for documenting API's built on ASP.NET Core
AspNetCore: Swagger tools for documenting API's built on ASP. ... If you're upgrading from 4.x to 5.x, there's several breaking changes to be...
Read more >Dependency Injection and Different ways to inject it using . ...
Also, discuss different ways to implement Dependency Injection. ... 4 min read ... Then, install the following NuGet Packages which we need for...
Read more >Comparing ASP.NET Core IoC container service lifetimes ...
– Transient, PerRequest/Scoped and Singleton. References: Service Lifetime in .NET Core: https://github.com/aspnet/DependencyInjection/blob/dev/ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve been looking at this today and although I can’t seem to get the middleware to work with scoped services as per the documentation, I was able to create a validator factory class that would create validators correctly when there are scoped dependencies.
I’m guessing this is a similar solution to the
ServiceProviderScopedValidatorFactory
that is now missing. I don’t know the reasons for the file going awry, or if it would be useful but I can always post a pull request if it will help others.Closed with #34