diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index aa4ad5bdd89b..d8f50d794cd0 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -67,7 +67,7 @@ reqwest-middleware = { version = "^0.3", features = ["json", "blocking", "multip {{/supportMiddleware}} {{/supportAsync}} {{#supportAsync}} -reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] } {{#supportMiddleware}} reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] } {{/supportMiddleware}} 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 b96063531e61..083f652d0fbb 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -275,7 +275,22 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{/required}} {{/supportAsync}} {{#supportAsync}} - // TODO: support file upload for '{{{baseName}}}' parameter + {{#required}} + {{^isNullable}} + local_var_form = local_var_form.file("{{{baseName}}}", {{{paramName}}}).await?; + {{/isNullable}} + {{#isNullable}} + match {{{paramName}}} { + Some(local_var_param_value) => { local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value).await?; }, + None => { unimplemented!("Required nullable form file param not supported"); }, + } + {{/isNullable}} + {{/required}} + {{^required}} + if let Some(local_var_param_value) = {{{paramName}}} { + local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value).await?; + } + {{/required}} {{/supportAsync}} {{/isFile}} {{^isFile}} diff --git a/samples/client/others/rust/reqwest/api-with-ref-param/Cargo.toml b/samples/client/others/rust/reqwest/api-with-ref-param/Cargo.toml index e4edc99b719c..e03bc9bf32ba 100644 --- a/samples/client/others/rust/reqwest/api-with-ref-param/Cargo.toml +++ b/samples/client/others/rust/reqwest/api-with-ref-param/Cargo.toml @@ -13,4 +13,4 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml index 2bbf314d7e82..cfe528698f9f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml @@ -13,5 +13,5 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] } reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs index 471556f03bd7..3f7732e20ada 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs @@ -529,7 +529,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U if let Some(local_var_param_value) = additional_metadata { local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); } - // TODO: support file upload for 'file' parameter + if let Some(local_var_param_value) = file { + local_var_form = local_var_form.file("file", local_var_param_value).await?; + } local_var_req_builder = local_var_req_builder.multipart(local_var_form); let local_var_req = local_var_req_builder.build()?; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml index 811475c96e17..9f214d948d6e 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml @@ -13,7 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] } async-trait = "^0.1" # TODO: propose to Yoshidan to externalize this as non google related crate, so that it can easily be extended for other cloud providers. google-cloud-token = "^0.1" diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs index 55fffa82b61a..0741583ef008 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs @@ -540,7 +540,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U if let Some(local_var_param_value) = additional_metadata { local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); } - // TODO: support file upload for 'file' parameter + if let Some(local_var_param_value) = file { + local_var_form = local_var_form.file("file", local_var_param_value).await?; + } local_var_req_builder = local_var_req_builder.multipart(local_var_form); let local_var_req = local_var_req_builder.build()?; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml index 3803423fe927..58f62ef28188 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml @@ -13,4 +13,4 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs index 471556f03bd7..3f7732e20ada 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs @@ -529,7 +529,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U if let Some(local_var_param_value) = additional_metadata { local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); } - // TODO: support file upload for 'file' parameter + if let Some(local_var_param_value) = file { + local_var_form = local_var_form.file("file", local_var_param_value).await?; + } local_var_req_builder = local_var_req_builder.multipart(local_var_form); let local_var_req = local_var_req_builder.build()?; diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml index a3312a3a7eef..99260d832361 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml @@ -13,4 +13,4 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest = { version = "^0.12", features = ["json", "stream", "multipart"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs index 471556f03bd7..3f7732e20ada 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs @@ -529,7 +529,9 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U if let Some(local_var_param_value) = additional_metadata { local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); } - // TODO: support file upload for 'file' parameter + if let Some(local_var_param_value) = file { + local_var_form = local_var_form.file("file", local_var_param_value).await?; + } local_var_req_builder = local_var_req_builder.multipart(local_var_form); let local_var_req = local_var_req_builder.build()?;