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 b96063531e616..083f652d0fbb4 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/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 471556f03bd7e..3f7732e20ada1 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/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs index 55fffa82b61af..0741583ef0082 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/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs index 471556f03bd7e..3f7732e20ada1 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/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs index 471556f03bd7e..3f7732e20ada1 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()?;