fix check suite and check run
@@ -986,7 +986,7 @@ pub struct GitHubCheckSuite {
pub head_sha: String,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub status: String,
- #[serde(default, skip_serializing_if = "String::is_empty")]
+ #[serde(default, skip_serializing_if = "String::is_empty", deserialize_with = "deserialize_null_string::deserialize")]
pub conclusion: String,
#[serde(default)]
pub app: GitHubApp,
@@ -1012,7 +1012,7 @@ pub struct GitHubCheckRun {
pub head_sha: String,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub status: String,
- #[serde(default, skip_serializing_if = "String::is_empty")]
+ #[serde(default, skip_serializing_if = "String::is_empty", deserialize_with = "deserialize_null_string::deserialize")]
pub conclusion: String,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub name: String,
@@ -1021,3 +1021,25 @@ pub struct GitHubCheckRun {
#[serde(default)]
pub app: GitHubApp,
}
+
+pub mod deserialize_null_string {
+ use serde::{self, Deserialize, Deserializer};
+
+ // The signature of a deserialize_with function must follow the pattern:
+ //
+ // fn deserialize<'de, D>(D) -> Result<T, D::Error>
+ // where
+ // D: Deserializer<'de>
+ //
+ // although it may also be generic over the output types T.
+ pub fn deserialize<'de, D>(deserializer: D) -> Result<String, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ // Sometimes this value is passed by the API as "null" which breaks the
+ // std User parsing. We fix that here.
+ let s = String::deserialize(deserializer).unwrap_or_default();
+
+ Ok(s)
+ }
+}
