diff --git a/.cargo/config.toml b/.cargo/config.toml index b589f69..762c4db 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -6,7 +6,10 @@ run_clippy = [ "--features", "latest schema_utils", "--fix", + "--allow-dirty", "--", + "-A", + "deprecated", "-D", "warnings", ] diff --git a/scripts/run_clippy.sh b/scripts/run_clippy.sh index 9bb5df1..00e45b9 100755 --- a/scripts/run_clippy.sh +++ b/scripts/run_clippy.sh @@ -11,7 +11,7 @@ COMMON_FEATURES_STR="${COMMON_FEATURES[*]}" for FEATURE in "${SCHEMA_VERSION_FEATURES[@]}"; do echo "🚀 Running Clippy with: --features \"$COMMON_FEATURES_STR $FEATURE\"" - cargo clippy --all-targets --no-default-features --features "$COMMON_FEATURES_STR $FEATURE" -- -D warnings + cargo clippy --all-targets --no-default-features --features "$COMMON_FEATURES_STR $FEATURE" -- -A deprecated -D warnings # stop on failure if [ $? -ne 0 ]; then diff --git a/src/generated_schema/2024_11_05/mcp_schema.rs b/src/generated_schema/2024_11_05/mcp_schema.rs index 0f0b8e4..cd4192a 100644 --- a/src/generated_schema/2024_11_05/mcp_schema.rs +++ b/src/generated_schema/2024_11_05/mcp_schema.rs @@ -5,8 +5,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7 -/// Generated at : 2025-03-02 12:41:59 +/// Hash : 6828f3ef6300b25dd2aaff2a2e5e81188bdbd22e +/// Generated at : 2025-03-08 08:33:48 /// ---------------------------------------------------------------------------- /// /// MCP Protocol Version @@ -5155,7 +5155,7 @@ impl ::std::convert::From for ServerResult { /// ], /// "properties": { /// "level": { -/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.", +/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message.", /// "$ref": "#/definitions/LoggingLevel" /// } /// } @@ -5192,7 +5192,7 @@ impl SetLevelRequest { /// ], /// "properties": { /// "level": { -/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.", +/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message.", /// "$ref": "#/definitions/LoggingLevel" /// } /// } @@ -5201,7 +5201,7 @@ impl SetLevelRequest { /// #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct SetLevelRequestParams { - ///The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message. + ///The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message. pub level: LoggingLevel, } ///Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. diff --git a/src/generated_schema/2024_11_05/schema_utils.rs b/src/generated_schema/2024_11_05/schema_utils.rs index cf16e3e..6d19422 100644 --- a/src/generated_schema/2024_11_05/schema_utils.rs +++ b/src/generated_schema/2024_11_05/schema_utils.rs @@ -587,6 +587,7 @@ impl FromStr for ClientJsonrpcResponse { #[serde(untagged)] pub enum ResultFromClient { ClientResult(ClientResult), + #[deprecated(since = "0.1.8", note = "Use `ClientResult::Result` with extra attributes instead.")] CustomResult(serde_json::Value), } @@ -1106,6 +1107,7 @@ impl FromStr for ServerJsonrpcResponse { #[serde(untagged)] pub enum ResultFromServer { ServerResult(ServerResult), + #[deprecated(since = "0.1.8", note = "Use `ServerResult::Result` with extra attributes instead.")] CustomResult(serde_json::Value), } @@ -1142,13 +1144,7 @@ impl<'de> serde::Deserialize<'de> for ResultFromServer { let result = ServerResult::deserialize(&raw_value); match result { - Ok(server_result) => { - if matches!(server_result, ServerResult::Result(_)) { - Ok(Self::CustomResult(raw_value)) - } else { - Ok(Self::ServerResult(server_result)) - } - } + Ok(server_result) => Ok(Self::ServerResult(server_result)), Err(_) => Ok(Self::CustomResult(raw_value)), } } diff --git a/src/generated_schema/draft/mcp_schema.rs b/src/generated_schema/draft/mcp_schema.rs index 784fd6f..f3eaeb4 100644 --- a/src/generated_schema/draft/mcp_schema.rs +++ b/src/generated_schema/draft/mcp_schema.rs @@ -5,8 +5,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7 -/// Generated at : 2025-03-02 12:41:59 +/// Hash : 6828f3ef6300b25dd2aaff2a2e5e81188bdbd22e +/// Generated at : 2025-03-08 08:33:48 /// ---------------------------------------------------------------------------- /// /// MCP Protocol Version @@ -5289,7 +5289,7 @@ impl ::std::convert::From for ServerResult { /// ], /// "properties": { /// "level": { -/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.", +/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message.", /// "$ref": "#/definitions/LoggingLevel" /// } /// } @@ -5326,7 +5326,7 @@ impl SetLevelRequest { /// ], /// "properties": { /// "level": { -/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.", +/// "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message.", /// "$ref": "#/definitions/LoggingLevel" /// } /// } @@ -5335,7 +5335,7 @@ impl SetLevelRequest { /// #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct SetLevelRequestParams { - ///The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message. + ///The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message. pub level: LoggingLevel, } ///Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. diff --git a/src/generated_schema/draft/schema_utils.rs b/src/generated_schema/draft/schema_utils.rs index 2c46067..4fa64e1 100644 --- a/src/generated_schema/draft/schema_utils.rs +++ b/src/generated_schema/draft/schema_utils.rs @@ -1142,13 +1142,7 @@ impl<'de> serde::Deserialize<'de> for ResultFromServer { let result = ServerResult::deserialize(&raw_value); match result { - Ok(server_result) => { - if matches!(server_result, ServerResult::Result(_)) { - Ok(Self::CustomResult(raw_value)) - } else { - Ok(Self::ServerResult(server_result)) - } - } + Ok(server_result) => Ok(Self::ServerResult(server_result)), Err(_) => Ok(Self::CustomResult(raw_value)), } } diff --git a/tests/test_deserialize.rs b/tests/test_deserialize.rs index 5008840..59bef77 100644 --- a/tests/test_deserialize.rs +++ b/tests/test_deserialize.rs @@ -222,7 +222,7 @@ mod test_deserialize { fn test_server_ping_result() { let message = get_message("res_ping"); assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::CustomResult(_server_result)) + if matches!(&server_message.result, ResultFromServer::ServerResult(_server_result)) )); } diff --git a/tests/test_serialize.rs b/tests/test_serialize.rs index 8d643d5..2059f2a 100644 --- a/tests/test_serialize.rs +++ b/tests/test_serialize.rs @@ -387,17 +387,29 @@ mod test_serialize { #[test] fn test_server_custom_result() { + let custom_result: serde_json::Map = json!({ + "custom_key":"custom_value", + "custom_number": 15.21 + }) + .as_object() + .unwrap() + .clone(); + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( RequestId::Integer(15), - ResultFromServer::CustomResult(json!({ - "result":{},"jsonrpc":"2.0","id":15 + ResultFromServer::ServerResult(ServerResult::Result(Result { + meta: None, + extra: Some(custom_result), })), )); let message: ServerMessage = re_serialize(message); assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::CustomResult(_)) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::Result(result) + if result.extra.is_some() + )) )); }