Repository: microsoft/kiota (csharp)

Issue:
Sending files to API
**Issue**
I'm encountering an issue when sending a file to the API using Kiota. The error message returned is:
```Expected a MultiPartBody instance, but got UploadCsvPostRequestBody```

The UploadCsvPostRequestBody class only has a string File property.

Has anyone managed to send a file via Kiota and can help me out here?

**Code Snippet**
```c#
    public async Task LoadFiles(InputFileChangeEventArgs e)
{
            using var stream = uploadedFile.OpenReadStream();
            using var memoryStream = new MemoryStream();
            await stream.CopyToAsync(memoryStream);
            var fileContent = memoryStream.ToArray();

            var base64File = Convert.ToBase64String(fileContent);

            var body = new UploadCsvPostRequestBody() { File = base64File };

            var response = await client.WorkItems.UploadCsv.PostAsync(body);
    }
``` 

**API Endpoint**
```c#
    [HttpPost(ApiRoutes.WorkItem.UploadCsv.Path)]
    [ProducesResponseType(StatusCodes.Status201Created)]
    [ProducesResponseType(StatusCodes.Status400BadRequest)]
    [Consumes("multipart/form-data", "text/csv")]
    public async Task<ActionResult<CsvUploadResult>> UploadCsv(IFormFile? file)
```

Pull request:
fixes #5638

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 958fa5fce4..a732d9914d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 
+- Fixed an issue where multipart request content would be ignored if other unstructured content was present in the description. [#5638](https://github.com/microsoft/kiota/issues/5638)
 - Fixed an issue where when generating Go code the deserializer for unions was using `CodeClass` as a filter and not `CodeInterface`. [#4844](https://github.com/microsoft/kiota/issues/4844)
 - Fixes mapping of `int16` format to the `integer` type rather than `double` when the type is `integer` or `number` [#5611](https://github.com/microsoft/kiota/issues/5611)
 - Fixes typing inconsistencies in generated code and libraries in Python [kiota-python#333](https://github.com/microsoft/kiota-python/issues/333)
diff --git a/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs b/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs
index aca62940e2..2ca1fd3009 100644
--- a/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs
+++ b/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs
@@ -41,7 +41,7 @@ internal static IEnumerable<OpenApiSchema> GetResponseSchemas(this OpenApiOperat
         return operation.RequestBody?.Content
                             .GetValidSchemas(structuredMimeTypes).FirstOrDefault();
     }
-    private static readonly StructuredMimeTypesCollection multipartMimeTypes = new(new string[] { "multipart/form-data" });
+    private static readonly StructuredMimeTypesCollection multipartMimeTypes = new(["multipart/form-data"]);
     internal static bool IsMultipartFormDataSchema(this IDictionary<string, OpenApiMediaType> source, StructuredMimeTypesCollection structuredMimeTypes)
     {
         return source.GetValidSchemas(structuredMimeTypes).FirstOrDefault() is OpenApiSchema schema &&
@@ -53,7 +53,7 @@ internal static bool IsMultipartTopMimeType(this IDictionary<string, OpenApiMedi
         ArgumentNullException.ThrowIfNull(structuredMimeTypes);
         if (structuredMimeTypes.Count == 0) return false;
         if (!source.ContainsKey(multipartMimeTypes.First())) return false;
-        if (source.Count == 1) return true;
+        if (source.Count == 1 || !source.Keys.Where(static x => !multipartMimeTypes.Contains(x)).Any(structuredMimeTypes.Contains)) return true;
         return structuredMimeTypes.First() == multipartMimeTypes.First();
     }
     internal static IEnumerable<OpenApiSchema> GetValidSchemas(this IDictionary<string, OpenApiMediaType> source, StructuredMimeTypesCollection structuredMimeTypes)


Test patch:
diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
index 32123dcde3..aaf4e8d449 100644
--- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
+++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
@@ -7603,6 +7603,16 @@ public async Task SupportsMultiPartFormAsRequestBodyWithDefaultMimeTypesAsync()
     post:
       requestBody:
         content:
+          text/csv:
+            schema:
+              type: object
+              properties:
+                file:
+                  type: string,
+                  format: binary
+            encoding:
+              file:
+                style: form
           multipart/form-data:
             schema:
               type: object