This library will not work if you use DI in your AbstractValidators.
See original GitHub issueI have nearly identical code to the issue here: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/issues/14
My validators have lots of DI going on, and I get a slew of errors out to my console when the app starts.
DevConf [10:18:27 Warning] MicroElements.Swashbuckle.FluentValidation.FluentValidationRules
GetValidator for type 'System.Collections.Generic.List`1[MyApp.API.ViewModels.ServiceUpdateViewModel]' fails.
System.InvalidOperationException: Cannot resolve 'FluentValidation.IValidator`1[System.Collections.Generic.List`1[MyApp.API.ViewModels.ServiceUpdateViewModel]]' from root provider because it requires scoped service 'MyApp.API.Validations.ServiceUpdateViewModelValidator'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at FluentValidation.AspNetCore.ServiceProviderValidatorFactory.CreateInstance(Type validatorType) in C:\Projects\FluentValidation\src\FluentValidation.AspNetCore\ServiceProviderValidatorFactory.cs:line 32
at MicroElements.Swashbuckle.FluentValidation.FluentValidationRules.Apply(Schema schema, SchemaFilterContext context) in /home/travis/build/micro-elements/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationRules.cs:line 92
We need a better way to access the validators.
Issue Analytics
- State:
- Created 5 years ago
- Comments:40 (21 by maintainers)
Top Results From Across the Web
Dependency Injection — FluentValidation documentation
Validators can be used with any dependency injection library, such as Microsoft.Extensions.DependencyInjection . To inject a validator for a specific model, ...
Read more >c# - .NET Core - FluentValidation inject
I am creating ASP.NET CORE (2.1) project and trying to use FluentValidation library (https://fluentvalidation.net/). Unfortunately I am getting ...
Read more >Using FluentValidation.DependencyInjectionExtensions To ...
This article discusses the use of FluentValidation.DependencyInjectionExtensions, an extension for the popular .NET validation library ...
Read more >Using Fluent Validation in ASP.NET Core
This is how you implement manual validation with Fluent Validation Library in ASP.NET Core Applications. You could have your own variants of course....
Read more >Adding validation to strongly typed configuration objects ...
In this post I describe how to to verify your strongly typed configuration objects are correctly bound to your config at start up...
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
Trying to reproduce and upload a sample for you. Not going so well so far.
add new issues for problems in new version. Old version locked to Swashbuckle < 4.0.0