Fix schemas for bigdecimal/rust_decimal (#248)

Both of these crates serialise decimals as strings, not as plain numbers
This commit is contained in:
Graham Esau 2023-09-17 20:31:24 +01:00 committed by GitHub
parent a5e51b22b3
commit db1dd47039
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 5 deletions

12
schemars/tests/decimal.rs Normal file
View file

@ -0,0 +1,12 @@
mod util;
use util::*;
#[test]
fn rust_decimal() -> TestResult {
test_default_generated_schema::<rust_decimal::Decimal>("rust_decimal")
}
#[test]
fn bigdecimal() -> TestResult {
test_default_generated_schema::<bigdecimal::BigDecimal>("bigdecimal")
}

View file

@ -0,0 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Decimal",
"type": "string",
"pattern": "^-?[0-9]+(\\.[0-9]+)?$"
}

View file

@ -0,0 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Decimal",
"type": "string",
"pattern": "^-?[0-9]+(\\.[0-9]+)?$"
}