Skip to content
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

#4804: Only include validation constraints with no groups by default #4805

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mc1arke
Copy link

@mc1arke mc1arke commented Dec 7, 2024

The current process for adding constraints into the schema presumes that all javax or jakarta validation annotations enforce a constraint, and doesn't take into account the 'groups' property of the annotation. This results in constrains being added to the schema that would only be applied for certain request, so incorrectly marks fields as required in the resulting schema where they may only be mandatory on a subset of requests. To overcome this, a new ValidationAnnotationFilter is being introduced which only treats a validation annotation as constraining the schema where the conditions on the filter are met be the annotation. The default implementation of this filter only treats constraints from annotations with no groups as being enforced to bring it inline with how the default Java Beans validation operates.

…by default

The current process for adding constraints into the schema presumes that
all javax or jakarta validation annotations enforce a constraint, and
doesn't take into account the 'groups' property of the annotation. This
results in constrains being added to the schema that would only be
applied for certain request, so incorrectly marks fields as required in
the resulting schema where they may only be mandatory on a subset of
requests. To overcome this, a new `ValidationAnnotationFilter` is being
introduced which only treats a validation annotation as constraining the
schema where the conditions on the filter are met be the annotation. The
default implementation of this filter only treats constraints from
annotations with no groups as being enforced to bring it inline with how
the default Java Beans validation operates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant