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 partial class MultipartRequest
public string Id { get ; }
public Address Address { get ; }
public Stream ProfileImage { get ; }
public IList < Stream > Pictures { get ; }
public virtual async Task < Response > Upload ( RequestContent content , string contentType , RequestContext context = null );
public virtual Response Upload ( MultipartRequest body , CancellationToken cancellationToken = default )
// RLC models (multipart part descriptors)
export interface MultipartRequestIdPartDescriptor {
export interface MultipartRequestAddressPartDescriptor {
export interface MultipartRequestProfileImagePartDescriptor {
body : string | Uint8Array | ReadableStream < Uint8Array > | NodeJS . ReadableStream | File ;
export interface MultipartRequestPicturesPartDescriptor {
body : string | Uint8Array | ReadableStream < Uint8Array > | NodeJS . ReadableStream | File ;
export interface Address {
export type MultipartRequest =
| MultipartRequestIdPartDescriptor
| MultipartRequestAddressPartDescriptor
| MultipartRequestProfileImagePartDescriptor
| MultipartRequestPicturesPartDescriptor
export interface UploadBodyParam {
export interface UploadMediaTypesParam {
contentType : "multipart/form-data" ;
export type UploadParameters = UploadMediaTypesParam & UploadBodyParam & RequestParameters ;
export interface Upload {
post ( options : UploadParameters ) : StreamableMethod < Upload204Response >;
export interface Routes {
/** Resource for '/' has methods for the following verbs: post */
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
// Not yet implemented. See issues:
// - RLC: https://github.com/Azure/autorest.typescript/issues/2568
// - Modular: https://github.com/Azure/autorest.typescript/issues/2422
public final class MultipartRequest {
public MultipartRequest (String id , Address address , FileDetails profileImage , List< Address > previousAddresses , List< FileDetails > pictures );
public void upload (MultipartRequest body);