Skip to content

Commit d8d2fb7

Browse files
committed
[Rust] Add rust-reqwest-object-query-param.yaml config, update samples
1 parent 81e7d99 commit d8d2fb7

34 files changed

Lines changed: 959 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
generatorName: rust
2+
outputDir: samples/client/others/rust/reqwest/object-query-param
3+
library: reqwest
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/objectQueryParam.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/rust
6+
validateSpec: "false"
7+
additionalProperties:
8+
supportAsync: "true"
9+
packageName: object-query-param-reqwest

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+
unimplemented!(
72+
"Only flat objects are supported, use parse_deep_object() instead"
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+
unimplemented!(
72+
"Only flat objects are supported, use parse_deep_object() instead"
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+
unimplemented!(
72+
"Only flat objects are supported, use parse_deep_object() instead"
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+
unimplemented!(
72+
"Only flat objects are supported, use parse_deep_object() instead"
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.gitignore
2+
.travis.yml
3+
Cargo.toml
4+
README.md
5+
docs/DefaultApi.md
6+
docs/ListNotRequiredParameter.md
7+
docs/ListPageQueryParameter.md
8+
git_push.sh
9+
src/apis/configuration.rs
10+
src/apis/default_api.rs
11+
src/apis/mod.rs
12+
src/lib.rs
13+
src/models/list_not_required_parameter.rs
14+
src/models/list_page_query_parameter.rs
15+
src/models/mod.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

0 commit comments

Comments
 (0)