File Upload
In OpenAPI 3.0, you can describe files uploaded directly with the request content and files uploaded with multipart
requests. Use the requestBody
keyword to describe the request payload containing a file. Under content
, specify the request media type (such as image/png
or application/octet-stream
). Files use a type: string
schema with format: binary
or format: base64
, depending on how the file contents will be encoded. For example:
This definition corresponds to an HTTP request that looks as follows:
Upload via Multipart Requests
To describe a file sent with other data, use the multipart
media type. For example:
The corresponding HTTP request payload will include multiple parts:
Multiple File Upload
Use the multipart
media type to define uploading an arbitrary number of files (an array of files):
The corresponding HTTP request will look as follows:
References
For more information about file upload in OpenAPI, see the following sections of the OpenAPI 3.0 Specification:
Considerations for File Uploads
Special Considerations for multipart Content
Did not find what you were looking for? Ask the community
Found a mistake? Let us know