]> git.proxmox.com Git - proxmox.git/commitdiff
proxmox-apt: fix serde attributes for API types
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 2 Dec 2023 13:45:57 +0000 (14:45 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 2 Dec 2023 13:45:57 +0000 (14:45 +0100)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
proxmox-apt/src/repositories/file.rs
proxmox-apt/src/repositories/repository.rs

index bfd783692da54cd12f162a78ed2bce47087b7efc..00fceb48a8cab34b231ad1b0cb9d0327708491f7 100644 (file)
@@ -61,9 +61,11 @@ pub struct APTRepositoryFile {
     pub repositories: Vec<APTRepository>,
 
     /// The file content, if already parsed.
+    #[serde(skip_serializing_if = "Option::is_none")]
     pub content: Option<String>,
 
     /// 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).
index e15cdfc36d74b067e198bf3258d5ba95b91aa28a..91bd64f253541ee4530e7d4c6da08d36a80bbab5 100644 (file)
@@ -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<APTRepositoryPackageType>,
 
     /// 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<String>,
 
     /// List of package distributions.
-    #[serde(skip_serializing_if = "Vec::is_empty")]
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
     pub suites: Vec<String>,
 
     /// List of repository components.
-    #[serde(skip_serializing_if = "Vec::is_empty")]
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
     pub components: Vec<String>,
 
     /// Additional options.
-    #[serde(skip_serializing_if = "Vec::is_empty")]
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
     pub options: Vec<APTRepositoryOption>,
 
     /// 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.