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

CLI - support for multipart form data request body #3031

Open
baywet opened this issue Aug 1, 2023 · 5 comments
Open

CLI - support for multipart form data request body #3031

baywet opened this issue Aug 1, 2023 · 5 comments
Labels
CLI Work to support generating CLIs with Kiota enhancement New feature or request
Milestone

Comments

@baywet
Copy link
Member

baywet commented Aug 1, 2023

details in #220 and linked pull requests.

@baywet baywet added CLI Work to support generating CLIs with Kiota enhancement New feature or request labels Aug 1, 2023
@baywet baywet added this to the Kiota v1.7 milestone Aug 1, 2023
@baywet baywet added this to Kiota Sep 8, 2023
@baywet baywet moved this to Todo in Kiota Sep 8, 2023
@sebastienlevert sebastienlevert modified the milestones: Kiota v1.7, Kiota v1.8 Sep 8, 2023
@baywet baywet modified the milestones: Kiota v1.7, Kiota v1.8 Oct 2, 2023
@sebastienlevert sebastienlevert changed the title CLI - support for multipart form data request boddy CLI - support for multipart form data request body Oct 6, 2023
@sebastienlevert
Copy link
Contributor

Support for input file only in multipart scenarios

@baywet baywet modified the milestones: Kiota v1.8, Kiota v1.9 Oct 24, 2023
@baywet baywet modified the milestones: Kiota v1.9, Kiota v1.10 Nov 2, 2023
@sebastienlevert sebastienlevert modified the milestones: Kiota v1.10, Backlog Dec 7, 2023
@KennethHoff
Copy link

Is this referring to the fact that multipart/form-data APIs uses a generic MultipartBody instead of a custom type-safe "MyCustomForm" model like how Json APIs function, or is this something else?

Around a year ago I tested out Kiota for TypeScript because I really liked it on my .Net application (which, at least at the time, interacted exclusively with JSON endpoints), but decided not to use it because I assumed it wasn't fully implemented yet. Earlier today I stumbled upon an external multipart/form-data endpoint on my .Net API as well, and I was equally surprised to see that MultipartBody was used in the C# client as well.

This begs the question; Is my schema incorrect and MultipartBody is a fallback "we were unable to parse the schema, so here's an escape-hatch", or are we supposed to interact with forms through this type-unsafe MultipartBody type? It feels so weird to me that Kiota generates a fairly good (Nullable notwithstanding..) type-safe models for JSON APIs, but falls back to some cryptic MultipartBody type for form APIs.

@baywet
Copy link
Member Author

baywet commented Nov 13, 2024

This issue is specific to generating CLI clients.

But to answer your question, multipart requires more information than "other serialization formats":

  • each part needs a name
  • each part needs a content type
  • file parts might also have additional metadata like the file name etc...

This is why kiota projects a reference to that wrapper object, so customers can assemble the payload from a mix of structured (generated types) and unstructured parts.

Let us know if you have any additional comments or questions.

@KennethHoff
Copy link

Could you not, at the very least, generate a stub like the following:

{
   public MultipartFormDataContent FirstName { get; init; }
   public MultipartFormDataContent LastName { get; init; }
   public MultipartFormDataContent File { get; init; }
}

Such that you can at least know which pros exist

@baywet
Copy link
Member Author

baywet commented Nov 13, 2024

That's a good suggestion. However the parent type for those properties also needs to handle the boundary.

@calebkiage calebkiage removed their assignment Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Work to support generating CLIs with Kiota enhancement New feature or request
Projects
Status: New📃
Development

No branches or pull requests

4 participants