radicle: fix schemars macro on FetchPackSizeLimit

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 macro[^0]:

> 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

[^0]: https://docs.rs/schemars_derive/latest/schemars_derive/derive.JsonSchema.html#attributes
This commit is contained in:
Fintan Halpenny 2025-07-14 11:06:43 +01:00
parent 4e429e4408
commit fe6a11d0db
3 changed files with 13 additions and 9 deletions

14
Cargo.lock generated
View File

@ -819,7 +819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -1765,7 +1765,7 @@ dependencies = [
"portable-atomic", "portable-atomic",
"portable-atomic-util", "portable-atomic-util",
"serde", "serde",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -2913,7 +2913,7 @@ dependencies = [
"errno", "errno",
"libc", "libc",
"linux-raw-sys 0.9.4", "linux-raw-sys 0.9.4",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -2948,9 +2948,9 @@ dependencies = [
[[package]] [[package]]
name = "schemars" name = "schemars"
version = "1.0.0-alpha.17" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ef2a6523400a2228db974a8ddc9e1d3deaa04f51bddd7832ef8d7e531bafcc" checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
dependencies = [ dependencies = [
"dyn-clone", "dyn-clone",
"ref-cast", "ref-cast",
@ -2961,9 +2961,9 @@ dependencies = [
[[package]] [[package]]
name = "schemars_derive" name = "schemars_derive"
version = "1.0.0-alpha.17" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6d4e1945a3c9e58edaa708449b026519f7f4197185e1b5dbc689615c1ad724d" checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -51,7 +51,7 @@ radicle-signals = { path = "crates/radicle-signals" }
radicle-ssh = { path = "crates/radicle-ssh", default-features = false } radicle-ssh = { path = "crates/radicle-ssh", default-features = false }
radicle-systemd = { path = "crates/radicle-systemd" } radicle-systemd = { path = "crates/radicle-systemd" }
radicle-term = { path = "crates/radicle-term" } radicle-term = { path = "crates/radicle-term" }
schemars = { version = "1.0.0-alpha.17" } schemars = { version = "1.0.4" }
serde = "1.0" serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
shlex = "1.1.0" shlex = "1.1.0"

View File

@ -148,7 +148,11 @@ impl Default for Limits {
#[cfg_attr( #[cfg_attr(
feature = "schemars", feature = "schemars",
derive(schemars::JsonSchema), 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 { pub struct FetchPackSizeLimit {
#[cfg_attr( #[cfg_attr(