Skip to content

v3.2: Ordered multipart examples #4746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better RFC2557 example
  • Loading branch information
handrews committed Jul 20, 2025
commit 67e81b91d51a917f63ba1c5c3cbb65eddfe0d66a
59 changes: 41 additions & 18 deletions src/oas.md
Original file line number Diff line number Diff line change
Expand Up @@ -1927,29 +1927,52 @@ multipart/mixed:

###### Example: Ordered Multipart With Required Header

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

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

```yaml
multipart/related:
schema:
items:
type: string
itemEncoding:
contentType: text/html
headers:
Content-Location:
required: true
content:
text/plain:
schema:
type: string
format: uri
components:
headers:
RFC2557ContentId:
description: Use Content-Location instead of Content-ID
schema: false
RFC2557ContentLocation:
required: true
content:
text/plain:
schema:
$comment: Use a full URI (not a relative reference)
type: string
format: uri
requestBodies:
RFC2557:
content:
multipart/related; type=text/html:
schema:
prefixItems:
- type: string
items:
anyOf:
- type: string
- $comment: To allow binary, this must always pass
prefixEncoding:
- contentType: text/html
headers:
Content-ID:
$ref: '#/components/headers/RFC2557ContentId'
Content-Location:
$ref: '#/components/headers/RFC2557ContentLocation'
itemEncoding:
contentType: text/html, text/css, text/javascript, image/*
headers:
Content-ID:
$ref: '#/components/headers/RFC2557ContentId'
Content-Location:
$ref: '#/components/headers/RFC2557ContentLocation'
```

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.

###### Example: Streaming Multipart

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