3

I am upgrading my ASP NET Core API from 2.0 to 3.1 in process I need to upgrade the swagger to 5.0 which brings lot of changes. One I am stuck with is an Controller that Handles file upload, Earlier


    public class FileUploadOperation : IOperationFilter
{
    public void Apply(Operation operation, OperationFilterContext context)
    {
        if (operation.OperationId.ToLower() == "apivaluesuploadpost")
        {
            operation.Parameters.Clear();
            operation.Parameters.Add(new NonBodyParameter
            {
                Name = "uploadedFile",
                In = "formData",
                Description = "Upload File",
                Required = true,
                Type = "file"
            });
            operation.Consumes.Add("multipart/form-data");
        }
    }
}

But After change OpenApiOperation and OpenApiParameters are introduced which changes lot of things such as by replacing strings by enums in parameters. I have a Action that expects an file

public async Task<IActionResult> FileUp([FromForm(Name = "formFile")]IFormFile formFile)

Now In new Parameters In is changed to have enum type of Header,Path,Query,Cookie but none of them make sense to this action . Can somebody help to resolve the changes without changing the API structure much.

ayush garg
  • 86
  • 6

0 Answers0