我正在尝试使用 C# NetCore7 中的最小 API 编写一个 http 帖子,它接收 IFormFile 文件。
最小API:
var group = app.MapGroup("Payment").WithTags("Payment").WithOpenApi();
group.MapPost("htmlToPdf", async (IFormFile file) =>
{
....
...
}).Accepts<IFormFile>("multipart/form-data");
当我使用swaggerUI上传文件时,文件为空:
我做错了什么?
问题出在以下行:
var group = app.MapGroup("Payment").WithTags("Payment").WithOpenApi();
当我删除以下
WithOpenAPi()
扩展时,上传文件正常工作!