-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating IFormFile in AspNet Core Controllers #2266
base: master
Are you sure you want to change the base?
Generating IFormFile in AspNet Core Controllers #2266
Conversation
Kind = OpenApiParameterKind.FormData, | ||
Name = "foo", | ||
Type = JsonObjectType.File, | ||
CollectionFormat = OpenApiParameterCollectionFormat.Multi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure if this is correct, but setting this was the only way I could find to trigger the branch of code that generated the collection of files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is something which is not yet supported with NSwag and OAS3.0...
{ | ||
return "System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Http.IFormFile>"; | ||
} | ||
|
||
return "System.Collections.Generic.IEnumerable<FileParameter>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my late reply.
I think one of the reasons to use FileParameter (also for controllers) is that the generated service class is independent of the technology (ASP.NET Core) and thus should use FileParameter but then this has to be transformed to a IFormFile when calling the generated methods from the generated controller. Not sure whether it's worth the effort though (and I'm personally not using controller generation).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that it's worth the effort to map FileParameter to IFormFile in this case, given that we're able to confirm that we're targeting ASP.Net core and it is the accepted way to handle multi-part form submissions with attached files. Is this something that we could keep moving forward?
@RicoSuter Are we able to get this PR merged? |
Are there still plans to merge? I am facing the same problem, and getting IFormFile will fix it. |
Updates for using IFormFile in AspNetCore controller generation.
Related: #2075