fix(radarr): serialize the credit type under the same key it is read from

Radarr sends and accepts the credit type as "type" in both directions,
but the field was only renamed for deserialization, so serializing a
Credit emitted "creditType" and a to_value round trip could not be read
back. Credit is only deserialized in production, so this affects tests
and any future serialization of the record, not the live API traffic.
This commit is contained in:
Dark-Alex-17 committed 2026-09-17 15:49:12 -06:00
1 parent 7b6d595397
commit 1d936c5cb5
2 files changed
+13 -4

No files matched your search

+1 -4
View File
@@ -127,10 +127,7 @@ pub struct Credit {
pub character: Option<String>,
pub department: Option<String>,
pub job: Option<String>,
#[serde(
rename(deserialize = "type"),
deserialize_with = "super::from_json_or_default"
)]
#[serde(rename = "type", deserialize_with = "super::from_json_or_default")]
pub credit_type: CreditType,
}
+12
View File
@@ -260,6 +260,18 @@ mod tests {
);
}
#[test]
fn test_credit_serializes_credit_type_under_the_type_key() {
let credit_json = serde_json::to_value(crew_credit()).unwrap();
assert_eq!(credit_json["type"], json!("crew"));
assert_none!(credit_json.get("creditType"));
assert_eq!(
serde_json::from_value::<Credit>(credit_json).unwrap(),
crew_credit()
);
}
#[test]
fn test_download_record_default_indexer_value() {
let json = r#"{