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

refs-#4703/#4702-@Pattern/@Size annotations handling on collections #4734

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

@frantuma frantuma force-pushed the fix-#4703/#4702-@Pattern/@Size-annotations-handling branch from 9eec26a to 19df1b6 Compare September 16, 2024 12:28
@@ -1519,6 +1519,11 @@ protected void applyBeanValidatorAnnotations(Schema property, Annotation[] annot
ArraySchema sp = (ArraySchema) property;
sp.setMinItems(size.min());
sp.setMaxItems(size.max());
}else if(openapi31 && property instanceof JsonSchema){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not sufficient I believe, we need to basically replace the instanceof checks with a test on the type and types. It would probably make sense to have some helper method working for both 3.0 and 3.1

so something like

boolean isStringSchema(Schema schema) {
 return "string".equals(schema.getType()) ||" (schema.getTypes() != null && schema.getTypes().contains("string")
}

and so on.
you would then use that instead e.g. of else if (property instanceof StringSchema) {

the same goes for array, number etc.

Also it would be probably a series of if, not else, as in oas 3.1 we could have type = "integer, string" so both can be applied

minor: please add spaces after and before { and }

The same would apply below for pattern

@micryc micryc force-pushed the fix-#4703/#4702-@Pattern/@Size-annotations-handling branch 3 times, most recently from 843baf9 to 7601ca6 Compare September 19, 2024 11:47
@micryc micryc force-pushed the fix-#4703/#4702-@Pattern/@Size-annotations-handling branch from 7601ca6 to dd98ce0 Compare September 19, 2024 11:51
@micryc micryc merged commit e924632 into master Sep 19, 2024
6 checks passed
@micryc micryc deleted the fix-#4703/#4702-@Pattern/@Size-annotations-handling branch September 19, 2024 16:19
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.

2 participants