Skip to content

Commit ce6de6d

Browse files
committed
Fixup dependency on forked serde_xml
1 parent 815a732 commit ce6de6d

181 files changed

Lines changed: 2052 additions & 158 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/samples-rust.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
working-directory: ${{ matrix.sample }}
5151
run: |
5252
set -e
53-
# Skip samples/client/petstore/rust/ as it's tests are failing.
53+
# Skip samples/client/petstore/rust/ as its tests are failing.
5454
if [[ "${{ matrix.sample }}" == "samples/client/petstore/rust/" ]]; then
5555
echo "Skipping tests for samples/client/petstore/rust/"
5656
exit 0

modules/openapi-generator/src/main/resources/rust-server-deprecated/Cargo.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ validator = { version = "0.16", features = ["derive"] }
101101
{{#usesXml}}
102102
# TODO: this should be updated to point at the official crate once
103103
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
104-
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
104+
#serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
105+
serde-xml-rs = "0.8"
105106
{{/usesXml}}
106107
{{#apiUsesMultipart}}
107108
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }

modules/openapi-generator/src/main/resources/rust-server-deprecated/models.mustache

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,19 @@ impl ::std::str::FromStr for {{{classname}}} {
159159
{{#arrayModelType}}
160160
{{#vendorExtensions}}{{#x-item-xml-name}}// Utility function for wrapping list elements when serializing xml
161161
#[allow(non_snake_case)]
162-
fn wrap_in_{{{x-item-xml-name}}}<S>(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
162+
fn wrap_in_{{{x-item-xml-name}}}<S>(items: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
163163
where
164164
S: serde::ser::Serializer,
165165
{
166-
serde_xml_rs::wrap_primitives(item, serializer, "{{{x-item-xml-name}}}")
167-
}
166+
use serde::ser::SerializeMap;
168167
168+
let mut map = serializer.serialize_map(None)?;
169+
for ref item in items {
170+
map.serialize_key("{{{x-item-xml-name}}}")?;
171+
map.serialize_value(item)?;
172+
}
173+
map.end()
174+
}
169175
{{/x-item-xml-name}}
170176
{{/vendorExtensions}}
171177
{{! vec}}
@@ -633,10 +639,10 @@ impl {{{classname}}} {
633639
#[allow(dead_code)]
634640
pub(crate) fn as_xml(&self) -> String {
635641
{{#xmlNamespace}}
636-
let mut namespaces = std::collections::BTreeMap::new();
637642
// An empty string is used to indicate a global namespace in xmltree.
638-
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
639-
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
643+
let config = serde_xml_rs::SerdeXml::new()
644+
.namespace("", Self::NAMESPACE);
645+
config.to_string(&self).expect("impossible to fail to serialize")
640646
{{/xmlNamespace}}
641647
{{^xmlNamespace}}
642648
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")

modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ validator = { version = "0.20", features = ["derive"] }
9696
{{#usesXml}}
9797
# TODO: this should be updated to point at the official crate once
9898
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
99-
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
100-
{{/usesXml}}
99+
#serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
100+
serde-xml-rs = "0.8"{{/usesXml}}
101101
{{#apiUsesMultipartFormData}}
102102
multipart = { version = "0.18", default-features = false, optional = true }
103103
{{/apiUsesMultipartFormData}}

modules/openapi-generator/src/main/resources/rust-server/models.mustache

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,18 @@ impl ::std::str::FromStr for {{{classname}}} {
158158
{{#arrayModelType}}
159159
{{#vendorExtensions}}{{#x-item-xml-name}}// Utility function for wrapping list elements when serializing xml
160160
#[allow(non_snake_case)]
161-
fn wrap_in_{{{x-item-xml-name}}}<S>(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
161+
fn wrap_in_{{{x-item-xml-name}}}<S>(items: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
162162
where
163163
S: serde::ser::Serializer,
164164
{
165-
serde_xml_rs::wrap_primitives(item, serializer, "{{{x-item-xml-name}}}")
165+
use serde::ser::SerializeMap;
166+
167+
let mut map = serializer.serialize_map(None)?;
168+
for ref item in items {
169+
map.serialize_key("{{{x-item-xml-name}}}")?;
170+
map.serialize_value(item)?;
171+
}
172+
map.end()
166173
}
167174
168175
{{/x-item-xml-name}}
@@ -632,10 +639,10 @@ impl {{{classname}}} {
632639
#[allow(dead_code)]
633640
pub(crate) fn as_xml(&self) -> String {
634641
{{#xmlNamespace}}
635-
let mut namespaces = std::collections::BTreeMap::new();
636642
// An empty string is used to indicate a global namespace in xmltree.
637-
namespaces.insert("".to_string(), Self::NAMESPACE.to_string());
638-
serde_xml_rs::to_string_with_namespaces(&self, namespaces).expect("impossible to fail to serialize")
643+
let config = serde_xml_rs::SerdeXml::new()
644+
.namespace("", Self::NAMESPACE);
645+
config.to_string(&self).expect("impossible to fail to serialize")
639646
{{/xmlNamespace}}
640647
{{^xmlNamespace}}
641648
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")

modules/openapi-generator/src/main/resources/rust-server/server-response-body-instance.mustache

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
1313
{{/x-has-namespace}}
1414
{{#x-has-namespace}}
15-
let mut namespaces = std::collections::BTreeMap::new();
16-
1715
// An empty string is used to indicate a global namespace in xmltree.
18-
namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string());
19-
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
16+
let config = serde_xml_rs::SerdeXml::new()
17+
.namespace("", {{{dataType}}}::NAMESPACE);
18+
let body = config.to_string(&body).expect("impossible to fail to serialize");
2019
{{/x-has-namespace}}
2120
{{/x-produces-xml}}
2221
{{#x-produces-json}}

samples/client/petstore/apex/force-app/main/default/classes/OASOrder.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class OASOrder {
4747
DELIVERED
4848
}
4949

50+
5051
/**
5152
* Order Status
5253
* @return status

samples/client/petstore/apex/force-app/main/default/classes/OASPet.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class OASPet {
5353
SOLD
5454
}
5555

56+
5657
/**
5758
* pet status in the store
5859
* @return status

samples/client/petstore/crystal/src/petstore/models/another_property_name_mapping.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ module Petstore
190190
end
191191
end
192192

193+
193194
end
194195

196+
195197
end

samples/client/petstore/crystal/src/petstore/models/api_response.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ module Petstore
187187
end
188188
end
189189

190+
190191
end
191192

193+
192194
end

0 commit comments

Comments
 (0)