Skip to content

Commit 67e81b9

Browse files
committed
Better RFC2557 example
1 parent 0b37bca commit 67e81b9

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
@@ -1927,29 +1927,52 @@ multipart/mixed:
19271927
19281928
###### Example: Ordered Multipart With Required Header
19291929
1930-
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.
1930+
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.
1931+
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.
19311932

1932-
See [Appendix D](appendix-d-serializing-headers-and-cookies) for an explanation of why `content: {text/plain: {...}}` is used to describe the header value.
1933+
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.
19331934

19341935
```yaml
1935-
multipart/related:
1936-
schema:
1937-
items:
1938-
type: string
1939-
itemEncoding:
1940-
contentType: text/html
1941-
headers:
1942-
Content-Location:
1943-
required: true
1944-
content:
1945-
text/plain:
1946-
schema:
1947-
type: string
1948-
format: uri
1936+
components:
1937+
headers:
1938+
RFC2557ContentId:
1939+
description: Use Content-Location instead of Content-ID
1940+
schema: false
1941+
RFC2557ContentLocation:
1942+
required: true
1943+
content:
1944+
text/plain:
1945+
schema:
1946+
$comment: Use a full URI (not a relative reference)
1947+
type: string
1948+
format: uri
1949+
requestBodies:
1950+
RFC2557:
1951+
content:
1952+
multipart/related; type=text/html:
1953+
schema:
1954+
prefixItems:
1955+
- type: string
1956+
items:
1957+
anyOf:
1958+
- type: string
1959+
- $comment: To allow binary, this must always pass
1960+
prefixEncoding:
1961+
- contentType: text/html
1962+
headers:
1963+
Content-ID:
1964+
$ref: '#/components/headers/RFC2557ContentId'
1965+
Content-Location:
1966+
$ref: '#/components/headers/RFC2557ContentLocation'
1967+
itemEncoding:
1968+
contentType: text/html, text/css, text/javascript, image/*
1969+
headers:
1970+
Content-ID:
1971+
$ref: '#/components/headers/RFC2557ContentId'
1972+
Content-Location:
1973+
$ref: '#/components/headers/RFC2557ContentLocation'
19491974
```
19501975

1951-
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.
1952-
19531976
###### Example: Streaming Multipart
19541977

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

0 commit comments

Comments
 (0)