-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
BUG @Size is ignored in properties using collections when using oas 3.1.0 #4702
Comments
micryc
added a commit
that referenced
this issue
Sep 16, 2024
frantuma
pushed a commit
that referenced
this issue
Sep 16, 2024
micryc
added a commit
that referenced
this issue
Sep 18, 2024
micryc
added a commit
that referenced
this issue
Sep 19, 2024
micryc
added a commit
that referenced
this issue
Sep 19, 2024
micryc
added a commit
that referenced
this issue
Sep 19, 2024
@Lorenzo-Bracci thank you for reporting this issue. Fixed by: #4734 and will be part of next release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
When generating OpenAPI 3.1.0 spec the
@Size
annotation on property with a collection type is ignored. The expected behaviour is that the generated property has bothmaxItems
andminItems
set but these properties are not found in the generated open api.Expected behaviour
@Size#min
is used to generateminItems
and@Size#max
is used to generatemaxItems
for the generated property schemaReproducer
The issues is reproduced in the following test:
Investigation with proposed solution
Looking at the
ModelResolver.applyBeanValidatorAnnotations
code (which is where information from bean validation annotations are processed), there is a check that theproperty
input parameter of typeSchema
is an instance ofArraySchema
. If the check succeeds then the information from@Size
is propagated to the generated schema (using theminItems
/maxItems
properties). Nevertheless for open api 3.1.0property
will be of typeJsonSchema
instead ofArraySchema
and therefore the information from@Size
will not be used. A possible solution would be that instead of using(property instanceof ArraySchema)
a check is performed on thetype
/types
fields ofproperty
to ensure that the property is an array schema.The text was updated successfully, but these errors were encountered: