Skip to content

Commit 499304e

Browse files
committed
[Rust] Update samples
1 parent 7c0025d commit 499304e

File tree

43 files changed

+1042
-7
lines changed

Some content is hidden

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

43 files changed

+1042
-7
lines changed

samples/client/others/rust/reqwest-regression-16119/src/apis/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
6161
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
6262
}
6363

64+
pub fn parse_flat_object(value: &serde_json::Value) -> Vec<(String, String)> {
65+
if let serde_json::Value::Object(object) = value {
66+
let mut params = vec![];
67+
68+
for (key, value) in object {
69+
match value {
70+
serde_json::Value::Object(_) => {
71+
unreachable!(
72+
"This should never be reached, there's a bug on the codegen or the templates"
73+
)
74+
}
75+
serde_json::Value::Array(array) => {
76+
for (i, value) in array.iter().enumerate() {
77+
params.push((format!("{key}[{i}]"), value.to_string()));
78+
}
79+
}
80+
serde_json::Value::String(s) => params.push((key.to_string(), s.clone())),
81+
_ => params.push((key.to_string(), value.to_string())),
82+
}
83+
}
84+
85+
return params;
86+
}
87+
88+
unimplemented!("Only objects are supported")
89+
}
90+
6491
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
6592
if let serde_json::Value::Object(object) = value {
6693
let mut params = vec![];

samples/client/others/rust/reqwest/api-with-ref-param/src/apis/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
6161
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
6262
}
6363

64+
pub fn parse_flat_object(value: &serde_json::Value) -> Vec<(String, String)> {
65+
if let serde_json::Value::Object(object) = value {
66+
let mut params = vec![];
67+
68+
for (key, value) in object {
69+
match value {
70+
serde_json::Value::Object(_) => {
71+
unreachable!(
72+
"This should never be reached, there's a bug on the codegen or the templates"
73+
)
74+
}
75+
serde_json::Value::Array(array) => {
76+
for (i, value) in array.iter().enumerate() {
77+
params.push((format!("{key}[{i}]"), value.to_string()));
78+
}
79+
}
80+
serde_json::Value::String(s) => params.push((key.to_string(), s.clone())),
81+
_ => params.push((key.to_string(), value.to_string())),
82+
}
83+
}
84+
85+
return params;
86+
}
87+
88+
unimplemented!("Only objects are supported")
89+
}
90+
6491
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
6592
if let serde_json::Value::Object(object) = value {
6693
let mut params = vec![];

samples/client/others/rust/reqwest/composed-oneof/src/apis/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
6161
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
6262
}
6363

64+
pub fn parse_flat_object(value: &serde_json::Value) -> Vec<(String, String)> {
65+
if let serde_json::Value::Object(object) = value {
66+
let mut params = vec![];
67+
68+
for (key, value) in object {
69+
match value {
70+
serde_json::Value::Object(_) => {
71+
unreachable!(
72+
"This should never be reached, there's a bug on the codegen or the templates"
73+
)
74+
}
75+
serde_json::Value::Array(array) => {
76+
for (i, value) in array.iter().enumerate() {
77+
params.push((format!("{key}[{i}]"), value.to_string()));
78+
}
79+
}
80+
serde_json::Value::String(s) => params.push((key.to_string(), s.clone())),
81+
_ => params.push((key.to_string(), value.to_string())),
82+
}
83+
}
84+
85+
return params;
86+
}
87+
88+
unimplemented!("Only objects are supported")
89+
}
90+
6491
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
6592
if let serde_json::Value::Object(object) = value {
6693
let mut params = vec![];

samples/client/others/rust/reqwest/emptyObject/src/apis/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
6161
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
6262
}
6363

64+
pub fn parse_flat_object(value: &serde_json::Value) -> Vec<(String, String)> {
65+
if let serde_json::Value::Object(object) = value {
66+
let mut params = vec![];
67+
68+
for (key, value) in object {
69+
match value {
70+
serde_json::Value::Object(_) => {
71+
unreachable!(
72+
"This should never be reached, there's a bug on the codegen or the templates"
73+
)
74+
}
75+
serde_json::Value::Array(array) => {
76+
for (i, value) in array.iter().enumerate() {
77+
params.push((format!("{key}[{i}]"), value.to_string()));
78+
}
79+
}
80+
serde_json::Value::String(s) => params.push((key.to_string(), s.clone())),
81+
_ => params.push((key.to_string(), value.to_string())),
82+
}
83+
}
84+
85+
return params;
86+
}
87+
88+
unimplemented!("Only objects are supported")
89+
}
90+
6491
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
6592
if let serde_json::Value::Object(object) = value {
6693
let mut params = vec![];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target/
2+
**/*.rs.bk
3+
Cargo.lock
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
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.gitignore
2+
.travis.yml
3+
Cargo.toml
4+
README.md
5+
docs/DefaultApi.md
6+
docs/ListNotRequiredParameter.md
7+
docs/ListPageQueryParameter.md
8+
docs/Page.md
9+
git_push.sh
10+
src/apis/configuration.rs
11+
src/apis/default_api.rs
12+
src/apis/mod.rs
13+
src/lib.rs
14+
src/models/list_not_required_parameter.rs
15+
src/models/list_page_query_parameter.rs
16+
src/models/mod.rs
17+
src/models/page.rs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.14.0-SNAPSHOT
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: rust
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "object-query-param-reqwest"
3+
version = "1.0.0"
4+
authors = ["OpenAPI Generator team and contributors"]
5+
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
6+
license = "Apache-2.0"
7+
edition = "2021"
8+
9+
[dependencies]
10+
serde = { version = "^1.0", features = ["derive"] }
11+
serde_json = "^1.0"
12+
serde_repr = "^0.1"
13+
url = "^2.5"
14+
reqwest = { version = "^0.12", default-features = false, features = ["json", "blocking", "multipart"] }

0 commit comments

Comments
 (0)