-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to customise the ProblemDetails object when capturing FluentValidation exceptions? #195
Comments
Hello @iaingymware! 👋 Have you looked at the sample in this repo? It shows a bunch of ways you can return custom problem details responses. You can return it directly from controllers, use It's hard to give more specific feedback without knowing more details about what you want to achieve. |
Hi @khellang I am using your example here linked just below to capture the FluentValidation Validation Exception. This uses the ProblemsDetailFactory to generate a ProblemsDetails instance with errors. This works brilliantly however I want to customise the returned ProblemDetails instance. Is there a way to use the sample Extension class however provide specific values, i.e Type, Title, Detail etc or do I need to write my own factory implementation similar to yours? Thanks |
If I'm not mistaken, the factory methods let you specify every single property of the problem details spec. |
So I could use this, but it doesnt accept errors as a param: Then we have this, but it accepts ModelStateDictionary (which i dont have as this is a web api) and no errors details: This which accepts error and status code, but no other params: and then this which is the same but an IDictionary version rather than SerializableError: Sorry if I've missed something or I am mistaken, but I dont see a way to pass all custom ProblemDetails values, as well as the errors dictionary? Thanks |
Hi @khellang Any update on how I should progress with this? Thanks |
Hi
I have this up and running when using the default ProblemDetails implementation, however I want to update some of the values, for example the type, to link out to my own documentation specifying the validation requirements.
I can't figure out how to override the ProblemDetails template.
I am currently using the example ProblemDetailsOptionsExtensions class from the samp and I can see it grabs the errors and adds them to a dictionary then passes this into a ProblemDetailsFactory class to generate the response.
How can I override the ProblemDetailsFactory implementation to provide my own Type data?
Thanks
The text was updated successfully, but these errors were encountered: