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

Generate with type BigDecimal for properties with minimum and maximum #1645

Closed
frjonsen opened this issue Nov 7, 2024 · 1 comment
Closed

Comments

@frjonsen
Copy link

frjonsen commented Nov 7, 2024

We encountered the same issue as have been mentioned elsewhere, where @DecimalMin and @DecimalMax annotations are not added when using "type": "number".

#1583
#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:

"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.

@unkish
Copy link
Collaborator

unkish commented Nov 9, 2024

Hi

Thank you for reporting.
Added clarification to wiki.

@unkish unkish closed this as completed Nov 9, 2024
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

No branches or pull requests

2 participants