Skip to content

Commit

Permalink
Revert unintentional change in behaviour when combining default and…
Browse files Browse the repository at this point in the history
… `required` attributes (#293)

Never add a field with the `default` attribute to a schema's `required` properties
  • Loading branch information
GREsau authored May 18, 2024
1 parent cf5be1b commit 7ecaa7f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 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

### Fixed:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions schemars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.20"
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
edition = "2021"
license = "MIT"
Expand All @@ -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.20", optional = true, path = "../schemars_derive" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.25"
dyn-clone = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion schemars/src/_private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn insert_object_property<T: ?Sized + JsonSchema>(
schema: 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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion schemars_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.20"
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
edition = "2021"
license = "MIT"
Expand Down

0 comments on commit 7ecaa7f

Please sign in to comment.