Hello, I can't find solution. Please advise how I should implement it.
I have the controller and it has FromForm parameter.
[Route("api/[controller]")]
[ApiController]
[Produces("application/json")]
public class OnboardingController : ControllerBase
{
[HttpPost]
[Route("save")]
[Consumes("multipart/form-data")]
[SwaggerResponse(HttpStatusCode.OK, typeof(OnboardingModel))]
public OnboardingModel Save([FromForm] OnboardingForm form)
{
return new OnboardingModel
{
User = new UserModel
{
Login = form.User?.Login,
Roles = form.User?.Roles?.Select(e => new RoleModel
{
Name = e.Name
}).ToList()
}
};
}
}
OnboardingForm has nested FromForm and array of another FromForm's
public class OnboardingForm
{
[Description("User")]
[FromForm(Name = "user")]
public UserForm User { get; set; }
}
public class UserForm
{
[Description("Login of user")]
[FromForm(Name = "login")]
public string Login { get; set; }
[Description("Avatar picture of user")]
[FromForm(Name = "avatar")]
public IFormFile AvatarFile { get; set; }
[Description("Roles of user")]
[FromForm(Name = "roles")]
public List<RoleForm> Roles { get; set; }
}
public class RoleForm
{
[Description("Name of role")]
[FromForm(Name = "name")]
public string Name { get; set; }
}
Hello, I can't find solution. Please advise how I should implement it.
I have the controller and it has FromForm parameter.
OnboardingForm has nested FromForm and array of another FromForm's
What I see in the swagger UI: https://www.screencast.com/t/kmwZSx3JtwB
And what I have expected:
That is my tests using Postman:
The Swagger document (auto generated):