Open iaingymware opened 1 year ago
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 Map
functions when configuring the middle ware etc.
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