diff --git a/wp_api/src/comments.rs b/wp_api/src/comments.rs index 1380fb9e..b0642072 100644 --- a/wp_api/src/comments.rs +++ b/wp_api/src/comments.rs @@ -1,5 +1,5 @@ use crate::{ - UserAvatarSize, UserId, WpApiParamOrder, WpResponseString, + JsonValue, UserAvatarSize, UserId, WpApiParamOrder, WpResponseString, date::WpGmtDateTime, impl_as_query_value_for_new_type, impl_as_query_value_from_to_string, posts::PostId, @@ -528,6 +528,9 @@ pub struct SparseComment { pub comment_type: Option, #[WpContext(edit, embed, view)] pub author_avatar_urls: Option>, + #[serde(flatten)] + #[WpContext(edit, embed, view)] + pub extras: Option, // meta field is omitted for now: https://github.com/Automattic/wordpress-rs/issues/422 } diff --git a/wp_api_integration_tests/tests/test_comments_immut.rs b/wp_api_integration_tests/tests/test_comments_immut.rs index 0d27d41f..f288388b 100644 --- a/wp_api_integration_tests/tests/test_comments_immut.rs +++ b/wp_api_integration_tests/tests/test_comments_immut.rs @@ -1,4 +1,5 @@ use wp_api::{ + JsonValue, comments::{ CommentId, CommentListParams, CommentRetrieveParams, CommentStatus, CommentType, SparseCommentFieldWithEditContext, SparseCommentFieldWithEmbedContext, @@ -207,6 +208,23 @@ async fn list_comments_with_edit_context_parse_author_avatar_urls( }); } +#[tokio::test] +#[parallel] +async fn parse_extras() { + let comment = api_client() + .comments() + .retrieve_with_edit_context(&FIRST_COMMENT_ID, &CommentRetrieveParams::default()) + .await + .assert_response() + .data; + match comment.extras { + JsonValue::Object(ref map) => { + assert!(map.contains_key("_links")); + } + _ => panic!("Expected extras to be an object"), + } +} + #[template] #[rstest] #[case::default(CommentListParams::default())]