summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCyborus <cyborus@noreply.codeberg.org>2024-07-09 04:31:54 +0200
committerCyborus <cyborus@noreply.codeberg.org>2024-07-09 04:31:54 +0200
commit189e6af0fcd3232c85c61db1cf28fb8ddc4755e0 (patch)
tree55e59bddc6121cb0799800dc1e50d6088f8e6cf0 /src
parentMerge pull request 'bump version to 0.3.1' (#60) from v0.3.1 into main (diff)
parentfix: null team reviews (diff)
downloadforgejo-api-189e6af0fcd3232c85c61db1cf28fb8ddc4755e0.tar.xz
forgejo-api-189e6af0fcd3232c85c61db1cf28fb8ddc4755e0.zip
Merge pull request 'fix parse error from team reviews request' (#64) from team-review-null into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/64
Diffstat (limited to 'src')
-rw-r--r--src/generated/structs.rs1
-rw-r--r--src/lib.rs12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/generated/structs.rs b/src/generated/structs.rs
index f7b8ce8..5b97ac9 100644
--- a/src/generated/structs.rs
+++ b/src/generated/structs.rs
@@ -2034,6 +2034,7 @@ pub struct PullRequest {
#[serde(deserialize_with = "crate::none_if_blank_url")]
pub patch_url: Option<url::Url>,
pub pin_order: Option<u64>,
+ #[serde(deserialize_with = "crate::requested_reviewers_ignore_null")]
pub requested_reviewers: Option<Vec<User>>,
pub state: Option<StateType>,
pub title: Option<String>,
diff --git a/src/lib.rs b/src/lib.rs
index d9b877e..abbb8a5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -358,6 +358,18 @@ where
.or(Ok(None))
}
+fn requested_reviewers_ignore_null<'de, D, DE>(
+ deserializer: D,
+) -> Result<Option<Vec<structs::User>>, DE>
+where
+ D: Deserializer<'de>,
+ DE: serde::de::Error,
+{
+ let list: Option<Vec<Option<structs::User>>> =
+ Option::deserialize(deserializer).map_err(DE::custom)?;
+ Ok(list.map(|list| list.into_iter().filter_map(|x| x).collect::<Vec<_>>()))
+}
+
fn parse_ssh_url(raw_url: &String) -> Result<Url, url::ParseError> {
// in case of a non-standard ssh-port (not 22), the ssh url coming from the forgejo API
// is actually parseable by the url crate, so try to do that first