We encountered the same issue as have been mentioned elsewhere, where @DecimalMin and @DecimalMax annotations are not added when using "type": "number".
Reading through the threads above, my take is that the solution is to use BigDecimal instead. Exactly how to do this wasn't quite specified, but I got it to work using, for example:
"state_of_charge": {
"type": "number",
"description": "State of charge as ratio (from 0 to 1)",
"javaType": "java.math.BigDecimal",
"minimum": 0,
"maximum": 1
}
While this is kind of annoying, I understand that it's a limitation of javax, and not of this library. However, it's specified in several places in the documentation of this library that using minimum and maximum for numbers is supported, but the limitation of only being supported for BigDecimal isn't mentioned. My suggestion would be to either generate these fields as BigDecimal by default (though this might be confusing as the type changes if the constraints are removed), or at least update the documentation to mention how this workaround works. When doing this I had to puzzle it together from reading various other issues.
We encountered the same issue as have been mentioned elsewhere, where
@DecimalMin
and@DecimalMax
annotations are not added when using"type": "number"
.https://github.com/joelittlejohn/jsonschema2pojo/issues/1583 https://github.com/joelittlejohn/jsonschema2pojo/issues/1418
Reading through the threads above, my take is that the solution is to use BigDecimal instead. Exactly how to do this wasn't quite specified, but I got it to work using, for example:
While this is kind of annoying, I understand that it's a limitation of javax, and not of this library. However, it's specified in several places in the documentation of this library that using
minimum
andmaximum
for numbers is supported, but the limitation of only being supported forBigDecimal
isn't mentioned. My suggestion would be to either generate these fields as BigDecimal by default (though this might be confusing as the type changes if the constraints are removed), or at least update the documentation to mention how this workaround works. When doing this I had to puzzle it together from reading various other issues.