Skip to content

Commit 3346ae8

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

File tree

44 files changed

+3234
-63
lines changed

Some content is hidden

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

44 files changed

+3234
-63
lines changed

.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-deprecated/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}}

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/c/unit-tests/manual-PetAPI.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
#include <stdlib.h>
33
#include <string.h>
44
#include <assert.h>
5+
#include <curl/curl.h>
56
#include "../api/PetAPI.h"
67

8+
void preInvokeFunc(CURL *curl);
79

810
#define EXAMPLE_CATEGORY_NAME "Example Category"
911
#define EXAMPLE_CATEGORY_ID 5
@@ -16,10 +18,15 @@
1618
#define EXAMPLE_TAG_2_ID 542353
1719
#define EXAMPLE_PET_ID 1234 // Set to 0 to generate a new pet
1820

21+
void preInvokeFunc(CURL *curl) {
22+
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
23+
printf("CURL pre-invoke function called - verbose mode enabled\n");
24+
}
1925

2026
int main() {
2127
// Add pet test
2228
apiClient_t *apiClient = apiClient_create();
29+
apiClient->curl_pre_invoke_func = preInvokeFunc;
2330

2431
char *categoryName = malloc(strlen(EXAMPLE_CATEGORY_NAME) + 1);
2532
strcpy(categoryName, EXAMPLE_CATEGORY_NAME);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2+
*.o
3+
*.a
4+
*.so
5+
6+
# Folders
7+
_obj
8+
_test
9+
10+
# Architecture specific extensions/prefixes
11+
*.[568vq]
12+
[568vq].out
13+
14+
*.cgo1.go
15+
*.cgo2.c
16+
_cgo_defun.c
17+
_cgo_gotypes.go
18+
_cgo_export.*
19+
20+
_testmain.go
21+
22+
*.exe
23+
*.test
24+
*.prof
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

0 commit comments

Comments
 (0)