Skip to content

Commit bb180d0

Browse files
committed
fix(rmcp): generate elicitation $schema as optional string in schemars
Use schemars(with = "String") on ElicitationSchema::$schema so schemars generates "type": "string" instead of ["string", "null"].
1 parent 312afb0 commit bb180d0

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

crates/rmcp/src/model/elicitation_schema.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ pub struct ElicitationSchema {
11211121
/// The 2025-11-25 protocol revision allows a `requestedSchema` to declare its
11221122
/// dialect. It is preserved verbatim so a declared dialect survives a
11231123
/// decode/re-encode round-trip instead of being silently dropped.
1124-
#[serde(rename = "$schema", skip_serializing_if = "Option::is_none")]
1124+
#[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
1125+
#[cfg_attr(feature = "schemars", schemars(with = "String"))]
11251126
pub schema: Option<Cow<'static, str>>,
11261127

11271128
/// Always "object" for elicitation schemas
@@ -1152,7 +1153,7 @@ pub struct ElicitationSchema {
11521153
#[derive(Deserialize, Serialize)]
11531154
#[serde(rename_all = "camelCase")]
11541155
struct ElicitationSchemaWire {
1155-
#[serde(rename = "$schema", skip_serializing_if = "Option::is_none")]
1156+
#[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
11561157
schema: Option<Cow<'static, str>>,
11571158
#[serde(rename = "type")]
11581159
type_: ObjectTypeConst,

crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,7 @@
965965
"properties": {
966966
"$schema": {
967967
"description": "Optional JSON Schema dialect identifier (the `$schema` keyword).\n\nThe 2025-11-25 protocol revision allows a `requestedSchema` to declare its\ndialect. It is preserved verbatim so a declared dialect survives a\ndecode/re-encode round-trip instead of being silently dropped.",
968-
"type": [
969-
"string",
970-
"null"
971-
]
968+
"type": "string"
972969
},
973970
"description": {
974971
"description": "Optional description of what this schema represents",

0 commit comments

Comments
 (0)