Skip to content

Commit 0c1fa8f

Browse files
committed
chore(deps): update schemars requirement from 0.8 to 0.9
1 parent 69712e3 commit 0c1fa8f

File tree

5 files changed

+32
-35
lines changed

5 files changed

+32
-35
lines changed

crates/rmcp/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ paste = { version = "1", optional = true }
2828
oauth2 = { version = "5.0", optional = true }
2929

3030
# for auto generate schema
31-
schemars = { version = "0.8", optional = true, features = ["chrono"] }
31+
schemars = { version = "0.9", optional = true }
3232

3333
# for image encoding
3434
base64 = { version = "0.22", optional = true }
@@ -133,7 +133,7 @@ schemars = ["dep:schemars"]
133133

134134
[dev-dependencies]
135135
tokio = { version = "1", features = ["full"] }
136-
schemars = { version = "0.8" }
136+
schemars = { version = "0.9", features = ["chrono04"] }
137137

138138
anyhow = "1.0"
139139
tracing-subscriber = { version = "0.3", features = [

crates/rmcp/src/handler/server/tool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ pub type DynCallToolHandler<S> = dyn for<'s> Fn(ToolCallContext<'s, S>) -> BoxFu
183183
pub struct Parameters<P>(pub P);
184184

185185
impl<P: JsonSchema> JsonSchema for Parameters<P> {
186-
fn schema_name() -> String {
186+
fn schema_name() -> Cow<'static, str> {
187187
P::schema_name()
188188
}
189189

190-
fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
190+
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
191191
P::json_schema(generator)
192192
}
193193
}

crates/rmcp/src/model.rs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,19 @@ macro_rules! const_string {
9898

9999
#[cfg(feature = "schemars")]
100100
impl schemars::JsonSchema for $name {
101-
fn schema_name() -> String {
102-
stringify!($name).to_string()
101+
fn schema_name() -> Cow<'static, str> {
102+
Cow::Borrowed(stringify!($name))
103103
}
104104

105-
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::schema::Schema {
106-
// Create a schema for a constant value of type String
107-
schemars::schema::Schema::Object(schemars::schema::SchemaObject {
108-
instance_type: Some(schemars::schema::InstanceType::String.into()),
109-
format: Some("const".to_string()),
110-
const_value: Some(serde_json::Value::String($value.into())),
111-
..Default::default()
112-
})
105+
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
106+
use serde_json::{Map, json};
107+
108+
let mut schema_map = Map::new();
109+
schema_map.insert("type".to_string(), json!("string"));
110+
schema_map.insert("format".to_string(), json!("const"));
111+
schema_map.insert("const".to_string(), json!($value));
112+
113+
schemars::Schema::from(schema_map)
113114
}
114115
}
115116
};
@@ -233,27 +234,23 @@ impl<'de> Deserialize<'de> for NumberOrString {
233234

234235
#[cfg(feature = "schemars")]
235236
impl schemars::JsonSchema for NumberOrString {
236-
fn schema_name() -> String {
237-
"NumberOrString".to_string()
237+
fn schema_name() -> Cow<'static, str> {
238+
Cow::Borrowed("NumberOrString")
238239
}
239240

240-
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::schema::Schema {
241-
schemars::schema::Schema::Object(schemars::schema::SchemaObject {
242-
subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
243-
one_of: Some(vec![
244-
schemars::schema::Schema::Object(schemars::schema::SchemaObject {
245-
instance_type: Some(schemars::schema::InstanceType::Number.into()),
246-
..Default::default()
247-
}),
248-
schemars::schema::Schema::Object(schemars::schema::SchemaObject {
249-
instance_type: Some(schemars::schema::InstanceType::String.into()),
250-
..Default::default()
251-
}),
252-
]),
253-
..Default::default()
254-
})),
255-
..Default::default()
256-
})
241+
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
242+
use serde_json::{Map, json};
243+
244+
let mut number_schema = Map::new();
245+
number_schema.insert("type".to_string(), json!("number"));
246+
247+
let mut string_schema = Map::new();
248+
string_schema.insert("type".to_string(), json!("string"));
249+
250+
let mut schema_map = Map::new();
251+
schema_map.insert("oneOf".to_string(), json!([number_schema, string_schema]));
252+
253+
schemars::Schema::from(schema_map)
257254
}
258255
}
259256

examples/servers/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tracing-subscriber = { version = "0.3", features = [
3333
futures = "0.3"
3434
rand = { version = "0.9", features = ["std"] }
3535
axum = { version = "0.8", features = ["macros"] }
36-
schemars = { version = "0.8", optional = true }
36+
schemars = { version = "0.9", optional = true }
3737
reqwest = { version = "0.12", features = ["json"] }
3838
chrono = "0.4"
3939
uuid = { version = "1.6", features = ["v4", "serde"] }

examples/transport/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tracing-subscriber = { version = "0.3", features = [
3737
] }
3838
futures = "0.3"
3939
rand = { version = "0.9" }
40-
schemars = { version = "0.8", optional = true }
40+
schemars = { version = "0.9", optional = true }
4141
hyper = { version = "1", features = ["client", "server", "http1"] }
4242
hyper-util = { version = "0.1", features = ["tokio"] }
4343
tokio-tungstenite = "0.27.0"

0 commit comments

Comments
 (0)