MicroElements.Swashbuckle.FluentValidation: This library will not work if you use DI in your AbstractValidators.
I 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 40 (21 by maintainers)
Trying to reproduce and upload a sample for you. Not going so well so far.