From 86f9aa27f2ad80c4dac2a62950f64e66fa60a197 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 16 Nov 2024 02:55:08 +0100 Subject: [PATCH] `hostmeta`: Schema improvements --- acrate-hostmeta/src/jrd.rs | 4 ++++ acrate-hostmeta/src/xrd.rs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/acrate-hostmeta/src/jrd.rs b/acrate-hostmeta/src/jrd.rs index f893bc0..24c7f68 100644 --- a/acrate-hostmeta/src/jrd.rs +++ b/acrate-hostmeta/src/jrd.rs @@ -17,6 +17,7 @@ pub struct ResourceDescriptorJRD { /// /// - /// + #[serde(skip_serializing_if = "Option::is_none")] pub subject: Option, /// Other names the resource described by this document can be referred to. @@ -70,6 +71,7 @@ pub struct ResourceDescriptorLinkJRD { /// /// - /// + #[serde(skip_serializing_if = "Option::is_none")] pub r#type: Option, /// URI to the resource put in relation. @@ -78,6 +80,7 @@ pub struct ResourceDescriptorLinkJRD { /// /// - /// + #[serde(skip_serializing_if = "Option::is_none")] pub href: Option, /// Titles of the resource put in relation in various languages. @@ -104,6 +107,7 @@ pub struct ResourceDescriptorLinkJRD { /// /// - /// + #[serde(skip_serializing_if = "Option::is_none")] pub template: Option, } diff --git a/acrate-hostmeta/src/xrd.rs b/acrate-hostmeta/src/xrd.rs index 0a66887..96e3a73 100644 --- a/acrate-hostmeta/src/xrd.rs +++ b/acrate-hostmeta/src/xrd.rs @@ -18,6 +18,7 @@ pub struct ResourceDescriptorXRD { /// - /// #[serde(rename = "Subject")] + #[serde(skip_serializing_if = "Option::is_none")] pub subject: Option, /// Other names the resource described by this document can be referred to. @@ -59,6 +60,7 @@ pub struct ResourceDescriptorXRD { /// - /// #[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Link")] pub struct ResourceDescriptorLinkXRD { /// The kind of relation established by the subject with the attached resource. /// @@ -76,6 +78,7 @@ pub struct ResourceDescriptorLinkXRD { /// - /// #[serde(rename = "@type")] + #[serde(skip_serializing_if = "Option::is_none")] pub r#type: Option, /// URI to the resource put in relation. @@ -85,6 +88,7 @@ pub struct ResourceDescriptorLinkXRD { /// - /// #[serde(rename = "@href")] + #[serde(skip_serializing_if = "Option::is_none")] pub href: Option, /// Titles of the resource put in relation in various languages. @@ -94,6 +98,7 @@ pub struct ResourceDescriptorLinkXRD { /// - /// #[serde(default)] + #[serde(rename = "Title")] pub titles: Vec, /// Additional information about the resource put in relation. @@ -103,6 +108,7 @@ pub struct ResourceDescriptorLinkXRD { /// - /// #[serde(default)] + #[serde(rename = "Property")] pub properties: Vec, /// Template to fill to get the URL to resource-specific information. @@ -112,6 +118,7 @@ pub struct ResourceDescriptorLinkXRD { /// - /// #[serde(rename = "@template")] + #[serde(skip_serializing_if = "Option::is_none")] pub template: Option, } @@ -121,16 +128,19 @@ pub struct ResourceDescriptorLinkXRD { /// /// - #[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Title")] pub struct ResourceDescriptorTitleXRD { /// The language of the title. #[serde(rename = "@lang")] pub language: String, /// The title itself. + #[serde(rename = "$text")] pub value: String, } #[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Property")] pub struct ResourceDescriptorPropertyXRD { /// The property identifier, or type. #[serde(rename = "@rel")]