Skip to content

Commit 775fb60

Browse files
committed
Better RFC2557 example
1 parent 23beb08 commit 775fb60

File tree

1 file changed

+41
-18
lines changed

1 file changed

+41
-18
lines changed

src/oas.md

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,29 +1902,52 @@ multipart/mixed:
19021902
19031903
###### Example: Ordered Multipart With Required Header
19041904
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.
1905+
As described in [[?RFC2557]], a set of resources making up a web pages can be sent in a `multipart/related` payload, preserving links among themselves by defining a `Content-Location` header for each page.
1906+
The first part is used as the root resource (unless using `Content-ID`, which RFC2557 advises against), 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.
19061907

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+
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.
19081909

19091910
```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
1911+
components:
1912+
headers:
1913+
RFC2557ContentId:
1914+
description: Use Content-Location instead of Content-ID
1915+
schema: false
1916+
RFC2557ContentLocation:
1917+
required: true
1918+
content:
1919+
text/plain:
1920+
schema:
1921+
$comment: Use a full URI (not a relative reference)
1922+
type: string
1923+
format: uri
1924+
requestBodies:
1925+
RFC2557:
1926+
content:
1927+
multipart/related; type=text/html:
1928+
schema:
1929+
prefixItems:
1930+
- type: string
1931+
items:
1932+
anyOf:
1933+
- type: string
1934+
- $comment: To allow binary, this must always pass
1935+
prefixEncoding:
1936+
- contentType: text/html
1937+
headers:
1938+
Content-ID:
1939+
$ref: '#/components/headers/RFC2557ContentId'
1940+
Content-Location:
1941+
$ref: '#/components/headers/RFC2557ContentLocation'
1942+
itemEncoding:
1943+
contentType: text/html, text/css, text/javascript, image/*
1944+
headers:
1945+
Content-ID:
1946+
$ref: '#/components/headers/RFC2557ContentId'
1947+
Content-Location:
1948+
$ref: '#/components/headers/RFC2557ContentLocation'
19241949
```
19251950

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-
19281951
###### Example: Streaming Multipart
19291952

19301953
This example assumes a device that takes large sets of pictures and streams them to the caller.

0 commit comments

Comments
 (0)