You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/oas.md
+116Lines changed: 116 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2178,6 +2178,122 @@ requestBody:
2178
2178
2179
2179
As seen in the [Encoding Object's `contentType` field documentation](#encoding-content-type), the empty schema for `items` indicates a media type of `application/octet-stream`.
2180
2180
2181
+
###### Example: Ordered, Unnamed Multipart
2182
+
2183
+
A `multipart/mixed` payload consisting of a JSON metadata document followed by an image which the metadata describes:
2184
+
2185
+
```yaml
2186
+
multipart/mixed:
2187
+
schema:
2188
+
type: array
2189
+
prefixItems:
2190
+
- # default content type for objects
2191
+
# is `application/json`
2192
+
type: object
2193
+
properties:
2194
+
author:
2195
+
type: string
2196
+
created:
2197
+
type: string
2198
+
format: datetime
2199
+
copyright:
2200
+
type: string
2201
+
license:
2202
+
type: string
2203
+
- # default content type for a schema without `type`
2204
+
# is `application/octet-stream`, which we need
2205
+
# to override.
2206
+
{}
2207
+
prefixEncoding:
2208
+
- # Encoding Object defaults are correct for JSON
2209
+
{}
2210
+
- contentType: image/*
2211
+
```
2212
+
2213
+
###### Example: Ordered Multipart With Required Header
2214
+
2215
+
As described in [[?RFC2557]], a set of resources making up a web page can be sent in a `multipart/related` payload, preserving links from the `text/html` document to subsidiary resources such as scripts, style sheets, and images by defining a `Content-Location` header for each page.
2216
+
The first part is used as the root resource (unless using `Content-ID`, which RFC2557 advises against and is forbidden in this example), so we use `prefixItems` and `prefixEncoding` to define that it must be an HTML resource, and then allow any of several different types of resources in any order to follow.
2217
+
2218
+
The `Content-Location` header is defined using `content: {text/plain: {...}}` to avoid percent-encoding its URI value; see [Appendix D](appendix-d-serializing-headers-and-cookies) for further details.
2219
+
2220
+
```yaml
2221
+
components:
2222
+
headers:
2223
+
RFC2557NoContentId:
2224
+
description: Use Content-Location instead of Content-ID
2225
+
schema: false
2226
+
RFC2557ContentLocation:
2227
+
required: true
2228
+
content:
2229
+
text/plain:
2230
+
schema:
2231
+
$comment: Use a full URI (not a relative reference)
2232
+
type: string
2233
+
format: uri
2234
+
requestBodies:
2235
+
RFC2557:
2236
+
content:
2237
+
multipart/related; type=text/html:
2238
+
schema:
2239
+
prefixItems:
2240
+
- type: string
2241
+
items:
2242
+
anyOf:
2243
+
- type: string
2244
+
- $comment: To allow binary, this must always pass
This example assumes a device that takes large sets of pictures and streams them to the caller.
2264
+
Unlike the previous example, we use `itemSchema` here because the expectation is that each image is processed as it arrives (or in small batches), since we know that buffering the entire stream will take too much memory.
2265
+
2266
+
```yaml
2267
+
multipart/mixed:
2268
+
itemSchema:
2269
+
$comment: A single data image from the device
2270
+
itemEncoding:
2271
+
contentType: image/jpg
2272
+
```
2273
+
2274
+
###### Example: Streaming Byte Ranges
2275
+
2276
+
For `multipart/byteranges` [[RFC9110]] [Section 14.6](https://www.rfc-editor.org/rfc/rfc9110.html#section-14.6), a `Content-Range` header is required:
2277
+
2278
+
See [Appendix D](appendix-d-serializing-headers-and-cookies) for an explanation of why `content: {text/plain: {...}}` is used to describe the header value.
2279
+
2280
+
```yaml
2281
+
multipart/byteranges:
2282
+
itemSchema:
2283
+
$comment: A single range of bytes from a video
2284
+
itemEncoding:
2285
+
contentType: video/mp4
2286
+
headers:
2287
+
Content-Range:
2288
+
required: true
2289
+
content:
2290
+
text/plain:
2291
+
schema:
2292
+
# The `pattern` regular expression that would
2293
+
# be included in practice is omitted for simplicity
2294
+
type: string
2295
+
```
2296
+
2181
2297
###### Example: Nested `multipart/mixed`
2182
2298
2183
2299
This defines a two-part `multipart/mixed` where the first part is a JSON array and the second part is a nested `multipart/mixed` document.
0 commit comments