From 059c80458897e5c678611e22ed34b9531faeeda8 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 24 May 2025 18:39:32 +0200 Subject: [PATCH] radicle: fix build when schemars feature is not enabled Commit b608a788 (cli: `rad config schema` emits JSON Schema, 2025-04-28) added a feature flag that enables the "schemars" optional dependency. Crate radicle-node doesn't use this feature. Crate radicle fails to compile when the feature is disabled. This is reproducible with "flake check". Fix it. Note that a "cargo build" of the entire workspace doesn't fail, because the feature is enabled due to "unification", since "radicle-cli" does use this feature. From https://doc.rust-lang.org/cargo/reference/resolver.html#features: > When building multiple packages in a workspace (such as with --workspace > or multiple -p flags), the features [of the dependencies] of all of those > packages are unified. If you have a circumstance where you want to avoid > that unification for different workspace members, you will need to build > them via separate cargo invocations. --- radicle/src/node/config.rs | 4 ++-- radicle/src/web.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/radicle/src/node/config.rs b/radicle/src/node/config.rs index cfbb430b..ab892b6e 100644 --- a/radicle/src/node/config.rs +++ b/radicle/src/node/config.rs @@ -298,7 +298,7 @@ impl Default for RateLimits { )] pub struct ConnectAddress( #[serde(with = "crate::serde_ext::string")] - #[schemars( + #[cfg_attr(feature = "schemars", schemars( with = "String", regex(pattern = r"^.+@.+:((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$"), extend("examples" = [ @@ -307,7 +307,7 @@ pub struct ConnectAddress( "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@seed.example.com:8776", "z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5@192.0.2.0:31337", ]), - )] + ))] PeerAddr, ); diff --git a/radicle/src/web.rs b/radicle/src/web.rs index 79b39ac9..41387b17 100644 --- a/radicle/src/web.rs +++ b/radicle/src/web.rs @@ -1,5 +1,4 @@ use crate::prelude::RepoId; -use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::collections::HashSet; @@ -30,8 +29,9 @@ pub struct Config { /// Pinned content. This can be used to pin certain content when /// listing, e.g. pin repositories on a web client. -#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Pinned { /// Pinned repositories. pub repositories: HashSet,