This doc details what emitters will generate for multipart request.
Common multipart request
When content-type of operation is “multipart/form-data”, the body payload is multipart payload.
@header contentType : "multipart/form-data" ,
@body body : MultipartRequest ,
address: "Address" = rest_field()
profile_image: FileType = rest_field( name = "profileImage" , is_multipart_file_input = True )
pictures: List[FileType] = rest_field( is_multipart_file_input = True )
self, body: Union[_models.MultipartRequest, JSON ], ** kwargs: Any
public final class MultipartRequest {
public MultipartRequest (String id , Address address , ProfileImageFileDetails profileImage , List< PicturesFileDetails > pictures );
public void upload (MultipartRequest body);
Multipart request with @multipartBody
With @multipartBody
, typespec author could define part of multipart request with more detailed info.
For example, typespec author could use File
model predefined in @typespec/http
to declare the requiredness of filename and
contentType.
address : HttpPart < Address >;
profileImage : HttpPart < File >;
previousAddresses : HttpPart < Address []>;
pictures : HttpPart < File >[];
@header contentType : "multipart/form-data" ,
@multipartBody body : MultipartRequest ,
address: "Address" = rest_field()
profile_image: FileType = rest_field( name = "profileImage" , is_multipart_file_input = True )
pictures: List[FileType] = rest_field( is_multipart_file_input = True )
self, body: Union[_models.MultipartRequest, JSON ], ** kwargs: Any
public final class MultipartRequest {
public MultipartRequest (String id , Address address , FileDetails profileImage , List< Address > previousAddresses , List< FileDetails > pictures );
public void upload (MultipartRequest body);