-
Notifications
You must be signed in to change notification settings - Fork 14
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
Debugging Validation Rules #10
Comments
The reason why this is not working is that the CreateProfileRequest inherits from a base class and IsObject and Properties don't work in that case. I'm not looking to do this as would have lots: Would say the FluentValidationSchemaProcessor needs to cater for inheritance. Thoughts? |
Hi Andrew, If you set the following setting to
|
It looks like NJsonSchema is correctly generating the AllOf references; however, modifying the FluentValidation schema processor to add the validation rules to the base class in the child class validator would not be a good idea. The reason for this is the validation rule for a property in the base class could conflict with other rules in the base class for other OpenAPI endpoints. |
It's fairly common to use an abstract base class, and the flatten hierarchy would work fine for me in that situation. Though may be able to achieve similar with composition (e.g. having pagination and other properties available on list endpoints). I think if you had multiple endpoints the validation would not conflict by having it on the base class, the calls are independent of one another and yet some implementation is common 🤔 |
Yes, I agree, inheritance is a fairly common use case to support without the flattened hierarchy. I'm trying to find a solution that would work with the OpenAPI spec and FluentValidation. Let me know if you have any ideas. https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/ In the case where you have the following models:
If you specify a validator on Cat and Dog for the parent Pet, we run into an issue with the OpenAPI spec on how to define the requirement on the Pet property for instance since Pet is shared by both Cat and Dog. |
Will loop back when I get the chance to take a proper look, think I understand the challenge. |
See #18 |
I've followed the steps as outlined and for some reason I'm not seeing the schema for the object change in the UI. I've confirmed that the validation is indeed being applied.
What's the best way of debugging the FluentValidationSchemaProcessor, and seeing that it picked up the validation rule? Have my LogLevel set to debug, and not seeing anything in the output.
Thanks.
The text was updated successfully, but these errors were encountered: