Revert unintentional change in behaviour when combining default
and required
attributes (#293)
Never add a field with the `default` attribute to a schema's `required` properties
This commit is contained in:
parent
cf5be1b266
commit
7ecaa7feab
5 changed files with 12 additions and 6 deletions
|
@ -1,5 +1,11 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [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
|
## [0.8.19] - 2024-05-06
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -318,7 +318,7 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars"
|
name = "schemars"
|
||||||
version = "0.8.19"
|
version = "0.8.20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.5.2",
|
"arrayvec 0.5.2",
|
||||||
"arrayvec 0.7.4",
|
"arrayvec 0.7.4",
|
||||||
|
@ -347,7 +347,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars_derive"
|
name = "schemars_derive"
|
||||||
version = "0.8.19"
|
version = "0.8.20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "schemars"
|
||||||
description = "Generate JSON Schemas from Rust code"
|
description = "Generate JSON Schemas from Rust code"
|
||||||
homepage = "https://graham.cool/schemars/"
|
homepage = "https://graham.cool/schemars/"
|
||||||
repository = "https://github.com/GREsau/schemars"
|
repository = "https://github.com/GREsau/schemars"
|
||||||
version = "0.8.19"
|
version = "0.8.20"
|
||||||
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -14,7 +14,7 @@ build = "build.rs"
|
||||||
rust-version = "1.60"
|
rust-version = "1.60"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
schemars_derive = { version = "=0.8.19", optional = true, path = "../schemars_derive" }
|
schemars_derive = { version = "=0.8.20", optional = true, path = "../schemars_derive" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0.25"
|
serde_json = "1.0.25"
|
||||||
dyn-clone = "1.0"
|
dyn-clone = "1.0"
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub fn insert_object_property<T: ?Sized + JsonSchema>(
|
||||||
schema: Schema,
|
schema: Schema,
|
||||||
) {
|
) {
|
||||||
obj.properties.insert(key.to_owned(), schema);
|
obj.properties.insert(key.to_owned(), schema);
|
||||||
if required || !(has_default || T::_schemars_private_is_option()) {
|
if !has_default && (required || !T::_schemars_private_is_option()) {
|
||||||
obj.required.insert(key.to_owned());
|
obj.required.insert(key.to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "schemars_derive"
|
||||||
description = "Macros for #[derive(JsonSchema)], for use with schemars"
|
description = "Macros for #[derive(JsonSchema)], for use with schemars"
|
||||||
homepage = "https://graham.cool/schemars/"
|
homepage = "https://graham.cool/schemars/"
|
||||||
repository = "https://github.com/GREsau/schemars"
|
repository = "https://github.com/GREsau/schemars"
|
||||||
version = "0.8.19"
|
version = "0.8.20"
|
||||||
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue