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
+92Lines changed: 92 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1869,6 +1869,98 @@ requestBody:
1869
1869
1870
1870
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`.
1871
1871
1872
+
###### Example: Ordered, Unnamed Multipart
1873
+
1874
+
A `multipart/mixed` payload consisting of a JSON metadata document followed by an image which the metadata describes:
1875
+
1876
+
```yaml
1877
+
multipart/mixed:
1878
+
schema:
1879
+
prefixItems:
1880
+
- # default content type for objects
1881
+
# is `application/json`
1882
+
type: object
1883
+
properties:
1884
+
author:
1885
+
type: string
1886
+
created:
1887
+
type: string
1888
+
format: datetime
1889
+
copyright:
1890
+
type: string
1891
+
license:
1892
+
type: string
1893
+
- # default content type for a schema without `type`
1894
+
# is `application/octet-stream`, which we need
1895
+
# to override.
1896
+
{}
1897
+
prefixEncoding:
1898
+
- # Encoding Object defaults are correct for JSON
1899
+
{}
1900
+
- contentType: image/*
1901
+
```
1902
+
1903
+
###### Example: Ordered Multipart With Required Header
1904
+
1905
+
As described in [[?RFC2557]], a set of HTML pages can be sent in a `multipart/related` payload, preserving links among themselves by defining a `Content-Location` header for each page.
1906
+
1907
+
See [Appendix D](appendix-d-serializing-headers-and-cookies) for an explanation of why `content: {text/plain: {...}}` is used to describe the header value.
1908
+
1909
+
```yaml
1910
+
multipart/related:
1911
+
schema:
1912
+
items:
1913
+
type: string
1914
+
itemEncoding:
1915
+
contentType: text/html
1916
+
headers:
1917
+
Content-Location:
1918
+
required: true
1919
+
content:
1920
+
text/plain:
1921
+
schema:
1922
+
type: string
1923
+
format: uri
1924
+
```
1925
+
1926
+
While the above example could have used `itemSchema` instead, if the payload is expected to be processed all at once, using `schema` ensures that tools will wait until the complete response is available before processing.
1927
+
1928
+
###### Example: Streaming Multipart
1929
+
1930
+
This example assumes a device that takes large sets of pictures and streams them to the caller.
1931
+
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.
1932
+
1933
+
```yaml
1934
+
multipart/mixed:
1935
+
itemSchema:
1936
+
$comment: A single data image from the device
1937
+
itemEncoding:
1938
+
contentType: image/jpg
1939
+
```
1940
+
1941
+
###### Example: Streaming Byte Ranges
1942
+
1943
+
For `multipart/byteranges` [[RFC9110]] [Section 14.6](https://www.rfc-editor.org/rfc/rfc9110.html#section-14.6), a `Content-Range` header is required:
1944
+
1945
+
See [Appendix D](appendix-d-serializing-headers-and-cookies) for an explanation of why `content: {text/plain: {...}}` is used to describe the header value.
1946
+
1947
+
```yaml
1948
+
multipart/byteranges:
1949
+
itemSchema:
1950
+
$comment: A single range of bytes from a video
1951
+
itemEncoding:
1952
+
contentType: video/mp4
1953
+
headers:
1954
+
Content-Range:
1955
+
required: true
1956
+
content:
1957
+
text/plain:
1958
+
schema:
1959
+
# A suitable "pattern" constraint for this
1960
+
# header is left as an exercise for the reader
1961
+
type: string
1962
+
```
1963
+
1872
1964
#### Responses Object
1873
1965
1874
1966
A container for the expected responses of an operation.
0 commit comments