diff --git a/CHANGELOG.md b/CHANGELOG.md index a686f085..59eb3ea0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [0.8.21] - 2024-05-23 + +### Fixed: + +- Fix `null` default not being set on generated schemas (https://github.com/GREsau/schemars/issues/295 / https://github.com/GREsau/schemars/pull/296) + +## [0.8.20] - 2024-05-18 + +### Fixed: + +- Revert unintentional change in behaviour when combining `default` and `required` attributes (https://github.com/GREsau/schemars/issues/292) + ## [0.8.19] - 2024-05-06 ### Fixed: diff --git a/Cargo.lock b/Cargo.lock index c415a5f4..4653cb93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,7 +303,7 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "schemars" -version = "0.8.19" +version = "0.8.21" dependencies = [ "arrayvec", "bigdecimal", @@ -329,7 +329,7 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.19" +version = "0.8.21" dependencies = [ "pretty_assertions", "proc-macro2", diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index ec9ff005..2ddbc07c 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -3,7 +3,7 @@ name = "schemars" description = "Generate JSON Schemas from Rust code" homepage = "https://graham.cool/schemars/" repository = "https://github.com/GREsau/schemars" -version = "0.8.19" +version = "0.8.21" authors = ["Graham Esau "] edition = "2021" license = "MIT" @@ -14,7 +14,7 @@ build = "build.rs" rust-version = "1.60" [dependencies] -schemars_derive = { version = "=0.8.19", optional = true, path = "../schemars_derive" } +schemars_derive = { version = "=0.8.21", optional = true, path = "../schemars_derive" } serde = "1.0" serde_json = "1.0.25" dyn-clone = "1.0" diff --git a/schemars/tests/default.rs b/schemars/tests/default.rs index fbc1033b..ab489f5e 100644 --- a/schemars/tests/default.rs +++ b/schemars/tests/default.rs @@ -30,6 +30,7 @@ where struct MyStruct { my_int: i32, my_bool: bool, + my_optional_string: Option, #[serde(serialize_with = "custom_serialize")] my_struct2: MyStruct2, #[serde( diff --git a/schemars/tests/expected/default.json b/schemars/tests/expected/default.json index 65b6a66a..d70fb57f 100644 --- a/schemars/tests/expected/default.json +++ b/schemars/tests/expected/default.json @@ -12,6 +12,13 @@ "type": "boolean", "default": false }, + "my_optional_string": { + "default": null, + "type": [ + "string", + "null" + ] + }, "my_struct2": { "$ref": "#/$defs/MyStruct2", "default": "i:0 b:false" diff --git a/schemars_derive/Cargo.toml b/schemars_derive/Cargo.toml index 996c0515..94ef0fd6 100644 --- a/schemars_derive/Cargo.toml +++ b/schemars_derive/Cargo.toml @@ -3,7 +3,7 @@ name = "schemars_derive" description = "Macros for #[derive(JsonSchema)], for use with schemars" homepage = "https://graham.cool/schemars/" repository = "https://github.com/GREsau/schemars" -version = "0.8.19" +version = "0.8.21" authors = ["Graham Esau "] edition = "2021" license = "MIT"