Skip to content

Commit

Permalink
Merge pull request #5639 from microsoft/fix/multipart-and-other-type
Browse files Browse the repository at this point in the history
fix/multipart and other type
  • Loading branch information
baywet authored Oct 22, 2024
2 parents 6c4376e + beea9d3 commit 37e9542
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 37e9542

Please sign in to comment.