From a8d723342fb9f215120619253ea3342cfb80e46b Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Sun, 17 Sep 2023 21:10:22 +0100 Subject: [PATCH] Cleanup and test updates for bigdecimal04 --- schemars/Cargo.toml | 3 +-- schemars/src/json_schema_impls/decimal.rs | 2 +- schemars/src/json_schema_impls/mod.rs | 6 +++++- schemars/tests/decimal.rs | 9 +++++++-- .../expected/{bigdecimal.json => bigdecimal03.json} | 0 schemars/tests/expected/bigdecimal04.json | 6 ++++++ 6 files changed, 20 insertions(+), 6 deletions(-) rename schemars/tests/expected/{bigdecimal.json => bigdecimal03.json} (100%) create mode 100644 schemars/tests/expected/bigdecimal04.json diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 75fec92..eda43d0 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -64,7 +64,6 @@ indexmap1 = ["indexmap"] raw_value = ["serde_json/raw_value"] # `bigdecimal` feature without version suffix is included only for back-compat - will be removed in a later version bigdecimal = ["bigdecimal03"] -bigdecimal04 = ["dep:bigdecimal04"] ui_test = [] @@ -126,7 +125,7 @@ required-features = ["semver"] [[test]] name = "decimal" -required-features = ["rust_decimal", "bigdecimal"] +required-features = ["rust_decimal", "bigdecimal03", "bigdecimal04"] [package.metadata.docs.rs] all-features = true diff --git a/schemars/src/json_schema_impls/decimal.rs b/schemars/src/json_schema_impls/decimal.rs index cd959ad..643ca44 100644 --- a/schemars/src/json_schema_impls/decimal.rs +++ b/schemars/src/json_schema_impls/decimal.rs @@ -33,7 +33,7 @@ macro_rules! decimal_impl { #[cfg(feature = "rust_decimal")] decimal_impl!(rust_decimal::Decimal); -#[cfg(feature = "bigdecimal")] +#[cfg(feature = "bigdecimal03")] decimal_impl!(bigdecimal03::BigDecimal); #[cfg(feature = "bigdecimal04")] decimal_impl!(bigdecimal04::BigDecimal); diff --git a/schemars/src/json_schema_impls/mod.rs b/schemars/src/json_schema_impls/mod.rs index 6066d9b..0c548eb 100644 --- a/schemars/src/json_schema_impls/mod.rs +++ b/schemars/src/json_schema_impls/mod.rs @@ -51,7 +51,11 @@ mod bytes; #[cfg(feature = "chrono")] mod chrono; mod core; -#[cfg(any(feature = "rust_decimal", feature = "bigdecimal"))] +#[cfg(any( + feature = "rust_decimal", + feature = "bigdecimal03", + feature = "bigdecimal04" +))] mod decimal; #[cfg(feature = "either")] mod either; diff --git a/schemars/tests/decimal.rs b/schemars/tests/decimal.rs index 7c3caa1..d245583 100644 --- a/schemars/tests/decimal.rs +++ b/schemars/tests/decimal.rs @@ -7,6 +7,11 @@ fn rust_decimal() -> TestResult { } #[test] -fn bigdecimal() -> TestResult { - test_default_generated_schema::("bigdecimal") +fn bigdecimal03() -> TestResult { + test_default_generated_schema::("bigdecimal03") +} + +#[test] +fn bigdecimal04() -> TestResult { + test_default_generated_schema::("bigdecimal04") } diff --git a/schemars/tests/expected/bigdecimal.json b/schemars/tests/expected/bigdecimal03.json similarity index 100% rename from schemars/tests/expected/bigdecimal.json rename to schemars/tests/expected/bigdecimal03.json diff --git a/schemars/tests/expected/bigdecimal04.json b/schemars/tests/expected/bigdecimal04.json new file mode 100644 index 0000000..855db6f --- /dev/null +++ b/schemars/tests/expected/bigdecimal04.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Decimal", + "type": "string", + "pattern": "^-?[0-9]+(\\.[0-9]+)?$" +} \ No newline at end of file