diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 091c40fe6253..13be947648ee 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -21,7 +21,7 @@ impl {{{classname}}}Client { pub trait {{{classname}}} { {{#operations}} {{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; + fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isListContainer}}Vec<{{/isListContainer}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#isListContainer}}>{{/isListContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; {{/operation}} {{/operations}} } @@ -30,16 +30,23 @@ pub trait {{{classname}}} { impl {{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isListContainer}}Vec<{{/isListContainer}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#isListContainer}}>{{/isListContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; + {{#hasFormParams}} + let form = [ + {{#formParams}} + ("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string()), + {{/formParams}} + ]; + {{/hasFormParams}} let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); -{{#queryParams}} + {{#queryParams}} query.append_pair("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string()); -{{/queryParams}} -{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}} + {{/queryParams}} + {{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}} if let Some(ref apikey) = configuration.api_key { let key = apikey.key.clone(); let val = match apikey.prefix { @@ -48,7 +55,7 @@ impl {{{classname}}} for {{{classname}}}Client { }; query.append_pair("{{{keyParamName}}}".to_owned(), val); } -{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}} + {{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}} query.finish() }; let uri_str = format!("{}{{{path}}}?{}", configuration.base_path, query_string{{#pathParams}}, {{{baseName}}}={{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}}); @@ -96,6 +103,10 @@ impl {{{classname}}} for {{{classname}}}Client { {{/bodyParams}} {{/hasBodyParam}} + {{#hasFormParams}} + req_builder = req_builder.form(&form); + {{/hasFormParams}} + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION b/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION index d077ffb477a4..afa636560641 100644 --- a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION +++ b/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.4-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs b/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs index 7771c6568d60..bc8802728c1e 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs @@ -30,8 +30,8 @@ impl PetApiClient { pub trait PetApi { fn add_pet(&self, pet: ::models::Pet) -> Result<(), Error>; fn delete_pet(&self, pet_id: i64, api_key: &str) -> Result<(), Error>; - fn find_pets_by_status(&self, status: Vec) -> Result, Error>; - fn find_pets_by_tags(&self, tags: Vec) -> Result, Error>; + fn find_pets_by_status(&self, status: Vec>) -> Result, Error>; + fn find_pets_by_tags(&self, tags: Vec>) -> Result, Error>; fn get_pet_by_id(&self, pet_id: i64) -> Result<::models::Pet, Error>; fn update_pet(&self, pet: ::models::Pet) -> Result<(), Error>; fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Result<(), Error>; @@ -46,7 +46,7 @@ impl PetApi for PetApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/pet?{}", configuration.base_path, query_string); @@ -65,6 +65,7 @@ impl PetApi for PetApiClient { req_builder = req_builder.json(&pet); + // send request let req = req_builder.build()?; @@ -78,7 +79,7 @@ impl PetApi for PetApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id); @@ -97,6 +98,7 @@ impl PetApi for PetApiClient { }; + // send request let req = req_builder.build()?; @@ -104,14 +106,14 @@ impl PetApi for PetApiClient { Ok(()) } - fn find_pets_by_status(&self, status: Vec) -> Result, Error> { + fn find_pets_by_status(&self, status: Vec>) -> Result, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); query.append_pair("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string()); - + query.finish() }; let uri_str = format!("{}/pet/findByStatus?{}", configuration.base_path, query_string); @@ -129,20 +131,21 @@ impl PetApi for PetApiClient { }; + // send request let req = req_builder.build()?; Ok(client.execute(req)?.error_for_status()?.json()?) } - fn find_pets_by_tags(&self, tags: Vec) -> Result, Error> { + fn find_pets_by_tags(&self, tags: Vec>) -> Result, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); query.append_pair("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string()); - + query.finish() }; let uri_str = format!("{}/pet/findByTags?{}", configuration.base_path, query_string); @@ -160,6 +163,7 @@ impl PetApi for PetApiClient { }; + // send request let req = req_builder.build()?; @@ -172,7 +176,7 @@ impl PetApi for PetApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id); @@ -196,6 +200,7 @@ impl PetApi for PetApiClient { + // send request let req = req_builder.build()?; @@ -208,7 +213,7 @@ impl PetApi for PetApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/pet?{}", configuration.base_path, query_string); @@ -227,6 +232,7 @@ impl PetApi for PetApiClient { req_builder = req_builder.json(&pet); + // send request let req = req_builder.build()?; @@ -238,9 +244,13 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; + let form = [ + ("name", &name.to_string()), + ("status", &status.to_string()), + ]; let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id); @@ -258,6 +268,8 @@ impl PetApi for PetApiClient { }; + req_builder = req_builder.form(&form); + // send request let req = req_builder.build()?; @@ -269,9 +281,13 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; + let form = [ + ("additionalMetadata", &additional_metadata.to_string()), + ("file", &file.to_string()), + ]; let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/pet/{petId}/uploadImage?{}", configuration.base_path, query_string, petId=pet_id); @@ -289,6 +305,8 @@ impl PetApi for PetApiClient { }; + req_builder = req_builder.form(&form); + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust-reqwest/src/apis/store_api.rs b/samples/client/petstore/rust-reqwest/src/apis/store_api.rs index 90a719df9293..2aa7f591d356 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/store_api.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/store_api.rs @@ -42,7 +42,7 @@ impl StoreApi for StoreApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id); @@ -56,6 +56,7 @@ impl StoreApi for StoreApiClient { + // send request let req = req_builder.build()?; @@ -69,7 +70,7 @@ impl StoreApi for StoreApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/store/inventory?{}", configuration.base_path, query_string); @@ -93,6 +94,7 @@ impl StoreApi for StoreApiClient { + // send request let req = req_builder.build()?; @@ -105,7 +107,7 @@ impl StoreApi for StoreApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id); @@ -119,6 +121,7 @@ impl StoreApi for StoreApiClient { + // send request let req = req_builder.build()?; @@ -131,7 +134,7 @@ impl StoreApi for StoreApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/store/order?{}", configuration.base_path, query_string); @@ -146,6 +149,7 @@ impl StoreApi for StoreApiClient { req_builder = req_builder.json(&order); + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust-reqwest/src/apis/user_api.rs b/samples/client/petstore/rust-reqwest/src/apis/user_api.rs index 8d14e2dc5cee..0a1b784a2e9c 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/user_api.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/user_api.rs @@ -29,8 +29,8 @@ impl UserApiClient { pub trait UserApi { fn create_user(&self, user: ::models::User) -> Result<(), Error>; - fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Result<(), Error>; - fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Result<(), Error>; + fn create_users_with_array_input(&self, user: Vec>) -> Result<(), Error>; + fn create_users_with_list_input(&self, user: Vec>) -> Result<(), Error>; fn delete_user(&self, username: &str) -> Result<(), Error>; fn get_user_by_name(&self, username: &str) -> Result<::models::User, Error>; fn login_user(&self, username: &str, password: &str) -> Result; @@ -46,7 +46,7 @@ impl UserApi for UserApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user?{}", configuration.base_path, query_string); @@ -61,6 +61,7 @@ impl UserApi for UserApiClient { req_builder = req_builder.json(&user); + // send request let req = req_builder.build()?; @@ -68,13 +69,13 @@ impl UserApi for UserApiClient { Ok(()) } - fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Result<(), Error> { + fn create_users_with_array_input(&self, user: Vec>) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user/createWithArray?{}", configuration.base_path, query_string); @@ -89,6 +90,7 @@ impl UserApi for UserApiClient { req_builder = req_builder.json(&user); + // send request let req = req_builder.build()?; @@ -96,13 +98,13 @@ impl UserApi for UserApiClient { Ok(()) } - fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Result<(), Error> { + fn create_users_with_list_input(&self, user: Vec>) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user/createWithList?{}", configuration.base_path, query_string); @@ -117,6 +119,7 @@ impl UserApi for UserApiClient { req_builder = req_builder.json(&user); + // send request let req = req_builder.build()?; @@ -130,7 +133,7 @@ impl UserApi for UserApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username); @@ -144,6 +147,7 @@ impl UserApi for UserApiClient { + // send request let req = req_builder.build()?; @@ -157,7 +161,7 @@ impl UserApi for UserApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username); @@ -171,6 +175,7 @@ impl UserApi for UserApiClient { + // send request let req = req_builder.build()?; @@ -185,7 +190,7 @@ impl UserApi for UserApiClient { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); query.append_pair("username", &username.to_string()); query.append_pair("password", &password.to_string()); - + query.finish() }; let uri_str = format!("{}/user/login?{}", configuration.base_path, query_string); @@ -199,6 +204,7 @@ impl UserApi for UserApiClient { + // send request let req = req_builder.build()?; @@ -211,7 +217,7 @@ impl UserApi for UserApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user/logout?{}", configuration.base_path, query_string); @@ -225,6 +231,7 @@ impl UserApi for UserApiClient { + // send request let req = req_builder.build()?; @@ -238,7 +245,7 @@ impl UserApi for UserApiClient { let query_string = { let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - + query.finish() }; let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username); @@ -253,6 +260,7 @@ impl UserApi for UserApiClient { req_builder = req_builder.json(&user); + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust/.openapi-generator/VERSION b/samples/client/petstore/rust/.openapi-generator/VERSION index d077ffb477a4..afa636560641 100644 --- a/samples/client/petstore/rust/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.4-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file