Open rigtigeEmil opened 11 months ago
@rigtigeEmil As we discussed on Discord, this is "I take pull requests" territory if you're interested in taking this work on.
@jeremydmiller I'm up for a challenge, but to be honest I don't have the slightest idea of where to start with it
The Wolverine.Http.FluentValidation package isn't very much code. The Wolverine.FluentValidation package does have a mechanism to swap out how it handles the failures. In your case, I think you make a pluggable strategy about how to go from the ValidationResults to an AspNetCore IResult. There'll be a little more work to modify the OpenAPI metadata on the HttpChain model
Is your feature request related to a problem? Please describe. I'm working on introducing Wolverine endpoints in an existing solution. This solution uses a model like this to describe any problems and return them to the caller:
Opting into Wolverine's
UseFluentValidationProblemDetailMiddleware()
causes automatic validation of abstract validators, and while the response above this looks similar to theProblemDetails
that Wolverine (and .NET in general) uses, it causes obvious issues since the response signature for4XX
calls are different.Describe the solution you'd like I'm assuming that somewhere Wolverine calls
ValidationResult result = SomeValidator.Validate(xx)
. It'd be nice to be able to define what should happen in this case, and what should be returned in the endpoint. Alternatively, a solution could be to opt into having a falsy validation result throw an exception that could then be caught in some middleware and mapped to any type.Describe alternatives you've considered Currently opting out of
UseFluentValidationProblemDetailMiddleware()
and manually creating an instance of a given validator, and if the result is invalid, returning400
.