question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swashbuckle v4 and Scoped Dependency Injection.

See original GitHub issue

https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/pull/22#discussion_r232811495

ScopedSwaggerMiddleware 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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
WarpSpideRcommented, Aug 27, 2019

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.

0reactions
petriashevcommented, Aug 28, 2019

Closed with #34

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found