azure-functions-openapi-extension
azure-functions-openapi-extension copied to clipboard
OpenApiRequestBody attribute with a "multipart/form-data" contentType throws exception when requesting swagger.json
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<HttpResponseData> 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
likely duplicate of https://github.com/Azure/azure-functions-openapi-extension/issues/433