Skip to content

Commit

Permalink
Add integer check for isNumberSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
micryc committed Sep 19, 2024
1 parent dd98ce0 commit a9510c3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1495,20 +1495,20 @@ protected void applyBeanValidatorAnnotations(Schema property, Annotation[] annot
}
}
if (annos.containsKey("javax.validation.constraints.Min")) {
if ("integer".equals(property.getType()) || "number".equals(property.getType())) {
if (isNumberSchema(property)) {
Min min = (Min) annos.get("javax.validation.constraints.Min");
property.setMinimum(new BigDecimal(min.value()));
}
}
if (annos.containsKey("javax.validation.constraints.Max")) {
if ("integer".equals(property.getType()) || "number".equals(property.getType())) {
if (isNumberSchema(property)) {
Max max = (Max) annos.get("javax.validation.constraints.Max");
property.setMaximum(new BigDecimal(max.value()));
}
}
if (annos.containsKey("javax.validation.constraints.Size")) {
Size size = (Size) annos.get("javax.validation.constraints.Size");
if ("integer".equals(property.getType()) || "number".equals(property.getType())) {
if (isNumberSchema(property)) {
property.setMinimum(new BigDecimal(size.min()));
property.setMaximum(new BigDecimal(size.max()));
}
Expand Down Expand Up @@ -3013,7 +3013,7 @@ protected boolean isStringSchema(Schema schema){
}

protected boolean isNumberSchema(Schema schema){
return "number".equals(schema.getType()) || (schema.getTypes() != null && schema.getTypes().contains("number"));
return "number".equals(schema.getType()) || (schema.getTypes() != null && schema.getTypes().contains("number")) || "integer".equals(schema.getType()) || (schema.getTypes() != null && schema.getTypes().contains("integer"));
}

protected Schema buildRefSchemaIfObject(Schema schema, ModelConverterContext context) {
Expand Down

0 comments on commit a9510c3

Please sign in to comment.