fix: allow deserializing notifications without params field (#729)

This commit is contained in:
Dale Seo 2026-03-09 15:56:27 -04:00 • committed by GitHub
commit fc757d41ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3834,4 +3834,15 @@ mod tests {
});
assert_eq!(json_url, expected_url_json);
}
#[test]
fn notification_without_params_should_deserialize_as_bare_jsonrpc_message() {
let payload = b"{\"method\":\"notifications/initialized\",\"jsonrpc\":\"2.0\"}";
let result: Result<JsonRpcMessage, _> = serde_json::from_slice(payload);
assert!(
matches!(result, Ok(JsonRpcMessage::Notification(_))),
"Expected Ok(Notification), got: {:?}",
result
);
}
}