From 3af0f9485b04e084def427209675a8b3631609c6 Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Wed, 9 Oct 2024 11:51:00 +0100 Subject: [PATCH 1/2] fix(api): make field_id optional for back compat --- api/src/resources/comment.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/resources/comment.rs b/api/src/resources/comment.rs index bff3be8..e1998ca 100644 --- a/api/src/resources/comment.rs +++ b/api/src/resources/comment.rs @@ -873,7 +873,7 @@ pub struct NewEntityWithSpan { pub name: EntityName, pub formatted_value: String, pub span: NewEntitySpan, - pub field_id: FieldId, + pub field_id: Option, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)] @@ -883,7 +883,7 @@ pub struct FieldId(pub String); pub struct NewEntityWithSpans { pub name: EntityName, pub formatted_value: String, - pub field_id: FieldId, + pub field_id: Option, pub spans: Vec, } @@ -900,7 +900,7 @@ pub struct Entity { pub name: EntityName, pub formatted_value: String, pub spans: Vec, - pub field_id: FieldId, + pub field_id: Option, } #[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Eq)] From 2c4fb96fb284dd34590753f228bf8abaf60c2f9e Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Wed, 9 Oct 2024 12:02:48 +0100 Subject: [PATCH 2/2] dont serialize field id when none --- api/src/resources/comment.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/src/resources/comment.rs b/api/src/resources/comment.rs index e1998ca..d5ca1df 100644 --- a/api/src/resources/comment.rs +++ b/api/src/resources/comment.rs @@ -873,6 +873,7 @@ pub struct NewEntityWithSpan { pub name: EntityName, pub formatted_value: String, pub span: NewEntitySpan, + #[serde(skip_serializing_if = "Option::is_none")] pub field_id: Option, } @@ -883,6 +884,7 @@ pub struct FieldId(pub String); pub struct NewEntityWithSpans { pub name: EntityName, pub formatted_value: String, + #[serde(skip_serializing_if = "Option::is_none")] pub field_id: Option, pub spans: Vec, } @@ -900,6 +902,7 @@ pub struct Entity { pub name: EntityName, pub formatted_value: String, pub spans: Vec, + #[serde(skip_serializing_if = "Option::is_none")] pub field_id: Option, }