From 1859be35882c497621e46159e7de5479d40934f5 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 2 Dec 2023 14:45:57 +0100 Subject: [PATCH] proxmox-apt: fix serde attributes for API types Signed-off-by: Dietmar Maurer --- proxmox-apt/src/repositories/file.rs | 4 +++- proxmox-apt/src/repositories/repository.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs index bfd78369..00fceb48 100644 --- a/proxmox-apt/src/repositories/file.rs +++ b/proxmox-apt/src/repositories/file.rs @@ -61,9 +61,11 @@ pub struct APTRepositoryFile { pub repositories: Vec, /// The file content, if already parsed. + #[serde(skip_serializing_if = "Option::is_none")] pub content: Option, /// Digest of the original contents. + #[serde(skip_serializing_if = "Option::is_none")] pub digest: Option<[u8; 32]>, } @@ -97,7 +99,7 @@ impl std::error::Error for APTRepositoryFileError { /// Additional information for a repository. pub struct APTRepositoryInfo { /// Path to the defining file. - #[serde(skip_serializing_if = "String::is_empty")] + #[serde(default, skip_serializing_if = "String::is_empty")] pub path: String, /// Index of the associated respository within the file (starting from 0). diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs index e15cdfc3..91bd64f2 100644 --- a/proxmox-apt/src/repositories/repository.rs +++ b/proxmox-apt/src/repositories/repository.rs @@ -157,28 +157,28 @@ pub struct APTRepositoryOption { /// Describes an APT repository. pub struct APTRepository { /// List of package types. - #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub types: Vec, /// List of repository URIs. - #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(default, skip_serializing_if = "Vec::is_empty")] #[serde(rename = "URIs")] pub uris: Vec, /// List of package distributions. - #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub suites: Vec, /// List of repository components. - #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub components: Vec, /// Additional options. - #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub options: Vec, /// Associated comment. - #[serde(skip_serializing_if = "String::is_empty")] + #[serde(default, skip_serializing_if = "String::is_empty")] pub comment: String, /// Format of the defining file.