Content types
Default behavior
Content type is assumed to be application/json
by default regardless of the type of the request or response body.
Examples:
Specify content type
The content type for an operation can be specified by including a header parameter named contentType
.
Request content type
Response content type:
Multiple content types
If there is multiples content types for the same body, they can be specified using a union of string.
Content type negotiation
There could be cases where you might the same endpoint to return different content depending on the content type requested. This can be achieved in 2 ways:
- using shared routes where different content response is represented as a different operation that share the same endpoint
- using overloads where each different content response is an overload.
For example assuming there is an api that lets you download the avatar as a png
or jpeg
which is decided by what Accept
header is sent.
Option 1: Using shared route
Option 2: Using overload
Multipart request
See Multipart docs