Skip to content

Fixup failing CI in rust-server due to xmltree dependency #21664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/samples-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
working-directory: ${{ matrix.sample }}
run: |
set -e
# Skip samples/client/petstore/rust/ as it's tests are failing.
# Skip samples/client/petstore/rust/ as its tests are failing.
if [[ "${{ matrix.sample }}" == "samples/client/petstore/rust/" ]]; then
echo "Skipping tests for samples/client/petstore/rust/"
exit 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ validator = { version = "0.16", features = ["derive"] }

# Crates included if required by the API definition
{{#usesXml}}
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
serde-xml-rs = "0.8"
{{/usesXml}}
{{#apiUsesMultipart}}
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,19 @@ impl ::std::str::FromStr for {{{classname}}} {
{{#arrayModelType}}
{{#vendorExtensions}}{{#x-item-xml-name}}// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_{{{x-item-xml-name}}}<S>(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_{{{x-item-xml-name}}}<S>(items: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "{{{x-item-xml-name}}}")
}
use serde::ser::SerializeMap;
let mut map = serializer.serialize_map(None)?;
for ref item in items {
map.serialize_key("{{{x-item-xml-name}}}")?;
map.serialize_value(item)?;
}
map.end()
}
{{/x-item-xml-name}}
{{/vendorExtensions}}
{{! vec}}
Expand Down Expand Up @@ -633,10 +639,10 @@ impl {{{classname}}} {
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
{{#xmlNamespace}}
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
{{/xmlNamespace}}
{{^xmlNamespace}}
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
{{/x-has-namespace}}
{{#x-has-namespace}}
let mut namespaces = std::collections::BTreeMap::new();

// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string());
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
let config = serde_xml_rs::SerdeXml::new()
.namespace("", {{{dataType}}}::NAMESPACE);
let body = config.to_string(&body).expect("impossible to fail to serialize");
{{/x-has-namespace}}
{{/x-produces-xml}}
{{#x-produces-json}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ validator = { version = "0.20", features = ["derive"] }

# Crates included if required by the API definition
{{#usesXml}}
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
serde-xml-rs = "0.8"
{{/usesXml}}
{{#apiUsesMultipartFormData}}
multipart = { version = "0.18", default-features = false, optional = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,18 @@ impl ::std::str::FromStr for {{{classname}}} {
{{#arrayModelType}}
{{#vendorExtensions}}{{#x-item-xml-name}}// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_{{{x-item-xml-name}}}<S>(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_{{{x-item-xml-name}}}<S>(items: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "{{{x-item-xml-name}}}")
use serde::ser::SerializeMap;
let mut map = serializer.serialize_map(None)?;
for ref item in items {
map.serialize_key("{{{x-item-xml-name}}}")?;
map.serialize_value(item)?;
}
map.end()
}
{{/x-item-xml-name}}
Expand Down Expand Up @@ -632,10 +639,10 @@ impl {{{classname}}} {
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
{{#xmlNamespace}}
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
{{/xmlNamespace}}
{{^xmlNamespace}}
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
{{/x-has-namespace}}
{{#x-has-namespace}}
let mut namespaces = std::collections::BTreeMap::new();

// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string());
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
let config = serde_xml_rs::SerdeXml::new()
.namespace("", {{{dataType}}}::NAMESPACE);
let body = config.to_string(&body).expect("impossible to fail to serialize");
{{/x-has-namespace}}
{{/x-produces-xml}}
{{#x-produces-json}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }

# Crates included if required by the API definition
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
serde-xml-rs = "0.8"
uuid = {version = "1.3.1", features = ["serde", "v4"]}

# Common between server and client features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,19 @@ impl AdditionalPropertiesWithNullable {

// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_snake_another_xml_inner<S>(item: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_snake_another_xml_inner<S>(items: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "snake_another_xml_inner")
}
use serde::ser::SerializeMap;

let mut map = serializer.serialize_map(None)?;
for ref item in items {
map.serialize_key("snake_another_xml_inner")?;
map.serialize_value(item)?;
}
map.end()
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnotherXmlArray(
Expand Down Expand Up @@ -953,10 +959,10 @@ impl AnotherXmlObject {
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
}
}

Expand Down Expand Up @@ -1854,10 +1860,10 @@ impl DuplicateXmlObject {
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
}
}

Expand Down Expand Up @@ -5191,13 +5197,19 @@ impl UuidObject {

// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_camelXmlInner<S>(item: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_camelXmlInner<S>(items: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "camelXmlInner")
}
use serde::ser::SerializeMap;

let mut map = serializer.serialize_map(None)?;
for ref item in items {
map.serialize_key("camelXmlInner")?;
map.serialize_value(item)?;
}
map.end()
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct XmlArray(
Expand Down Expand Up @@ -5695,9 +5707,9 @@ impl XmlObject {
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1652,11 +1652,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
HeaderValue::from_str("text/xml")
.expect("Unable to create Content-Type header for text/xml"));
// XML Body
let mut namespaces = std::collections::BTreeMap::new();

// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), models::AnotherXmlObject::NAMESPACE.to_string());
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
let config = serde_xml_rs::SerdeXml::new()
.namespace("", models::AnotherXmlObject::NAMESPACE);
let body = config.to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
},
XmlOtherPostResponse::BadRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }

# Crates included if required by the API definition
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
serde-xml-rs = "0.8"
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
multipart = { version = "0.16", default-features = false, optional = true }
uuid = {version = "1.3.1", features = ["serde", "v4"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ serde_json = "1.0"
validator = { version = "0.20", features = ["derive"] }

# Crates included if required by the API definition
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
serde-xml-rs = "0.8"
uuid = { version = "1.17.0", features = ["serde", "v4"]}

# Common between server and client features
Expand Down
40 changes: 27 additions & 13 deletions samples/server/petstore/rust-server/output/openapi-v3/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,18 @@ impl AdditionalPropertiesWithNullable {

// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_snake_another_xml_inner<S>(item: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_snake_another_xml_inner<S>(items: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "snake_another_xml_inner")
use serde::ser::SerializeMap;

let mut map = serializer.serialize_map(None)?;
for ref item in items {
map.serialize_key("snake_another_xml_inner")?;
map.serialize_value(item)?;
}
map.end()
}

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -952,10 +959,10 @@ impl AnotherXmlObject {
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
}
}

Expand Down Expand Up @@ -1853,10 +1860,10 @@ impl DuplicateXmlObject {
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
}
}

Expand Down Expand Up @@ -5190,11 +5197,18 @@ impl UuidObject {

// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_camelXmlInner<S>(item: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_camelXmlInner<S>(items: &Vec<String>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "camelXmlInner")
use serde::ser::SerializeMap;

let mut map = serializer.serialize_map(None)?;
for ref item in items {
map.serialize_key("camelXmlInner")?;
map.serialize_value(item)?;
}
map.end()
}

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -5694,9 +5708,9 @@ impl XmlObject {
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn as_xml(&self) -> String {
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
let config = serde_xml_rs::SerdeXml::new()
.namespace("", Self::NAMESPACE);
config.to_string(&self).expect("impossible to fail to serialize")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1748,11 +1748,10 @@ impl<T, C, ReqBody> hyper::service::Service<(Request<ReqBody>, C)> for Service<T
HeaderValue::from_str("text/xml")
.expect("Unable to create Content-Type header for text/xml"));
// XML Body
let mut namespaces = std::collections::BTreeMap::new();

// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), models::AnotherXmlObject::NAMESPACE.to_string());
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
let config = serde_xml_rs::SerdeXml::new()
.namespace("", models::AnotherXmlObject::NAMESPACE);
let body = config.to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = body_from_string(body);

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ serde_json = "1.0"
validator = { version = "0.20", features = ["derive"] }

# Crates included if required by the API definition
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
serde-xml-rs = "0.8"
multipart = { version = "0.18", default-features = false, optional = true }
uuid = { version = "1.17.0", features = ["serde", "v4"]}

Expand Down
Loading