radicle: allow for unknown fields in Project deserialization
Allow unknown fields to pass through when deserializing the `Project` payload. This allows the deserialization to be more resilient when unknown fields are added, e.g. from the CLI, and improves backwards-compatability when new fields may be added in the future. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
43b0b2b426
commit
9b719d0cca
|
|
@ -47,6 +47,9 @@ impl<'de> Deserialize<'de> for Project {
|
|||
Name,
|
||||
Description,
|
||||
DefaultBranch,
|
||||
/// A catch-all variant to allow for unknown fields
|
||||
#[allow(dead_code)]
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
struct ProjectVisitor;
|
||||
|
|
@ -86,6 +89,7 @@ impl<'de> Deserialize<'de> for Project {
|
|||
}
|
||||
default_branch = Some(map.next_value()?);
|
||||
}
|
||||
Field::Unknown(_) => continue,
|
||||
}
|
||||
}
|
||||
let name = name.ok_or_else(|| de::Error::missing_field("name"))?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue