Azure / Azure/azure-functions-openapi-extension
OpenApiRequestBody attribute with a "multipart/form-data" contentType throws exception when requesting swagger.json
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
There is an issue when trying to add the OpenApiRequestBody attribute with a "multipart/form-data" contentType. Trying to request the swagger.json returns an exception: "An item with the same key has already been added. Key: multiPartFormDataModel." Here is a sample of my code:
```
[Function(nameof(Upload))]
[OpenApiOperation(
operationId: "Upload",
Visibility = OpenApiVisibilityType.Important)]
[OpenApiRequestBody(
contentType: "multipart/form-data",
bodyType: typeof(MultiPartFormDataModel),
Required = true)]
public async Task Upload([HttpTrigger(AuthorizationLevel.Function, "post", Route = "form/multipart")] HttpRequestData req, ILogger log)
{
}
public class MultiPartFormDataModel
{
public byte[] File { get; set; }
}
```
I pulled the repo to try to reproduce and this issue seems to be fixed in the main branch. Only present in v1.3.0
Contributor guide
Assessment
This issue has not been assessed yet.