Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle: fix schemars macro on FetchPackSizeLimit
Merged fintohaps opened 9 months ago

While running cargo-semver-checks, there was an issue that was surfaced regarding serde(into), serde(try_from) and schemars(transparent) being used, and they are incompatible.

This appeared to be a semver issue, on the side of schemars, since the issue would only appear when adding radicle as a fresh dependency. The intuition for this is that once schemars was updated locally, the same error appeared when attempting to build the radicle crate.

To avoid this, schemars provides a ! operator for the macro1:

You can also “unset” serde attributes by including them with a ! prefix in a schemars attribute, which will make schemars ignore the corresponding serde attribute item

1

https://docs.rs/schemars_derive/latest/schemars_derive/derive.JsonSchema.html#attributes

3 files changed +13 -9 4e429e44 fe6a11d0
modified Cargo.lock
@@ -819,7 +819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [
 "libc",
-
 "windows-sys 0.52.0",
+
 "windows-sys 0.59.0",
]

[[package]]
@@ -1765,7 +1765,7 @@ dependencies = [
 "portable-atomic",
 "portable-atomic-util",
 "serde",
-
 "windows-sys 0.52.0",
+
 "windows-sys 0.59.0",
]

[[package]]
@@ -2913,7 +2913,7 @@ dependencies = [
 "errno",
 "libc",
 "linux-raw-sys 0.9.4",
-
 "windows-sys 0.52.0",
+
 "windows-sys 0.59.0",
]

[[package]]
@@ -2948,9 +2948,9 @@ dependencies = [

[[package]]
name = "schemars"
-
version = "1.0.0-alpha.17"
+
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "88ef2a6523400a2228db974a8ddc9e1d3deaa04f51bddd7832ef8d7e531bafcc"
+
checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
dependencies = [
 "dyn-clone",
 "ref-cast",
@@ -2961,9 +2961,9 @@ dependencies = [

[[package]]
name = "schemars_derive"
-
version = "1.0.0-alpha.17"
+
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "c6d4e1945a3c9e58edaa708449b026519f7f4197185e1b5dbc689615c1ad724d"
+
checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
dependencies = [
 "proc-macro2",
 "quote",
modified Cargo.toml
@@ -51,7 +51,7 @@ radicle-signals = { path = "crates/radicle-signals" }
radicle-ssh = { path = "crates/radicle-ssh", default-features = false }
radicle-systemd = { path = "crates/radicle-systemd" }
radicle-term = { path = "crates/radicle-term" }
-
schemars = { version = "1.0.0-alpha.17" }
+
schemars = { version = "1.0.4" }
serde = "1.0"
serde_json = "1.0"
shlex = "1.1.0"
modified crates/radicle/src/node/config.rs
@@ -148,7 +148,11 @@ impl Default for Limits {
#[cfg_attr(
    feature = "schemars",
    derive(schemars::JsonSchema),
-
    schemars(transparent)
+
    schemars(transparent),
+
    // serde's transparent and try_from/into will conflict, so we tell schemars
+
    // to ignore them for its generation.
+
    schemars(!try_from),
+
    schemars(!into),
)]
pub struct FetchPackSizeLimit {
    #[cfg_attr(