Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SamuelMcAravey
Copy link

Updates for using IFormFile in AspNetCore controller generation.

Related: #2075

Kind = OpenApiParameterKind.FormData,
Name = "foo",
Type = JsonObjectType.File,
CollectionFormat = OpenApiParameterCollectionFormat.Multi
Copy link
Author

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.

Copy link
Owner

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...

@SamuelMcAravey SamuelMcAravey changed the title Users/samuelmcaravey/iformfile fix Generating IFormFile in AspNet Core Controllers Jun 26, 2019
{
return "System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Http.IFormFile>";
}

return "System.Collections.Generic.IEnumerable<FileParameter>";
Copy link
Owner

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?

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?

@Evangelinexx
Copy link

@RicoSuter Are we able to get this PR merged?

@ForgeColeColon
Copy link

Are there still plans to merge? I am facing the same problem, and getting IFormFile will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants