azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

OpenApiRequestBody attribute with a "multipart/form-data" contentType throws exception when requesting swagger.json

Open LauroSalinas opened this issue 2 years ago • 1 comments

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

LauroSalinas avatar May 12 '22 22:05 LauroSalinas

likely duplicate of https://github.com/Azure/azure-functions-openapi-extension/issues/433

dannythomas13 avatar May 20 '22 18:05 dannythomas13