micro-elements/MicroElements.Swashbuckle.FluentValidation

Swashbuckle.AspNetCore 6.3.0 compatibility - Problems after upgrading

guimabdo opened this issue · 1 comments

Hello,

When upgrading Swashbuckle.AspNetCore from 6.2.3 to 6.3.0, the following error starts to occur:

warn: MicroElements.Swashbuckle.FluentValidation.FluentValidationRules[0]
      Error on apply rules for operation 'myapi'.
      System.MissingMethodException: Method not found: 'Microsoft.OpenApi.Models.OpenApiSchema Swashbuckle.AspNetCore.SwaggerGen.ISchemaGenerator.GenerateSchema(System.Type, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository, System.Reflection.MemberInfo, System.Reflection.ParameterInfo)'.
         at MicroElements.Swashbuckle.FluentValidation.SwashbuckleSchemaProvider.GetSchemaForType(Type type)
         at MicroElements.Swashbuckle.FluentValidation.FluentValidationOperationFilter.ApplyInternal(OpenApiOperation operation, OperationFilterContext context) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/Swashbuckle/FluentValidationOperationFilter.cs:line 116
         at MicroElements.Swashbuckle.FluentValidation.FluentValidationOperationFilter.Apply(OpenApiOperation operation, OperationFilterContext context) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/Swashbuckle/FluentValidationOperationFilter.cs:line 81

This causes parameter validation not to be passed to the OpenApi spec.

In Swashbuckle.AspNetCore 6.3.0 the ISchemaGenerator.GenerateSchema method has changed:

domaindrivendev/Swashbuckle.AspNetCore@eaf3bc8#diff-c46727841a546aa50b440ab58346c751cc554e3dcc0383df7da7920523e641b6

I suppose that this change started the problem.

Just to add that I'm also encountering this same issue having upgraded to 6.3.0 of Swashbuckle. I imagine this library will need updating to understand the new routeInfo argument on GenerateSchema as well as changing the minimum required version.