-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Schema for BigDecimal is not correct #123
Comments
I was able to make it work by mapping a BigDecimal to an I ran some tests and it worked great for my use case, and thought that it was best to share it, and thus I made PR #224 . Hope it helps |
This is mostly fixed in v0.8.14, in that the schema will now match how |
Just as a note — we use rust_decimal schemas in our input jsonschemas, and we currently expect schemars |
Problem
0.8.8
version added schema forBigDecimal
, but it is incorrect, because BigDecimal serialized as string, and can be deserialized from string, number or integer.Details
Current schema
For example:
gives
see https://www.jsonschemavalidator.net/s/s2ULf39e as well.
And about deserialization:
Solution
I don't have any good solutions. The problem is: this type have different schemas for deserialization and serialization. One possible solution: use most common type here - string and then add description and pattern to it.
I recently faced same problem in my work project, and we came up with 2 wrapper types, which have different
JsonSchema
implementations, but this is quite ugly and would not be suitable for this lib I think.The text was updated successfully, but these errors were encountered: