Skip to content

Commit d1cc23f

Browse files
committed
Improve example, add security considerations.
1 parent b6dde47 commit d1cc23f

File tree

1 file changed

+47
-19
lines changed

1 file changed

+47
-19
lines changed

src/oas.md

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ These fields MAY be used either with or without the RFC6570-style serialization
17081708

17091709
| Field Name | Type | Description |
17101710
| ---- | :----: | ---- |
1711-
| <a name="encoding-content-type"></a>contentType | `string` | The `Content-Type` for encoding a specific property. The value is a comma-separated list, each element of which is either a specific media type (e.g. `image/png`) or a wildcard media type (e.g. `image/*`). Default value depends on the property type as shown in the table below. |
1711+
| <a name="encoding-content-type"></a>contentType | `string` | The `Content-Type` for encoding a specific property. The value is a comma-separated list, each element of which is either a specific media type (e.g. `image/png`) or a wildcard media type (e.g. `image/*`). See [Detecting Media Types](#detecting media types) for related security concerns. Default value depends on the property type as shown in the table below. |
17121712
| <a name="encoding-headers"></a>headers | Map[`string`, [Header Object](#header-object) \| [Reference Object](#reference-object)] | A map allowing additional information to be provided as headers. `Content-Type` is described separately and SHALL be ignored in this section. This field SHALL be ignored if the media type is not a `multipart`. |
17131713

17141714
This object MAY be extended with [Specification Extensions](#specification-extensions).
@@ -1974,29 +1974,52 @@ multipart/mixed:
19741974
19751975
###### Example: Ordered Multipart With Required Header
19761976
1977-
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.
1977+
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.
1978+
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.
19781979

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

19811982
```yaml
1982-
multipart/related:
1983-
schema:
1984-
items:
1985-
type: string
1986-
itemEncoding:
1987-
contentType: text/html
1988-
headers:
1989-
Content-Location:
1990-
required: true
1991-
content:
1992-
text/plain:
1993-
schema:
1994-
type: string
1995-
format: uri
1983+
components:
1984+
headers:
1985+
RFC2557ContentId:
1986+
description: Use Content-Location instead of Content-ID
1987+
schema: false
1988+
RFC2557ContentLocation:
1989+
required: true
1990+
content:
1991+
text/plain:
1992+
schema:
1993+
$comment: Use a full URI (not a relative reference)
1994+
type: string
1995+
format: uri
1996+
requestBodies:
1997+
RFC2557:
1998+
content:
1999+
multipart/related; type=text/html:
2000+
schema:
2001+
prefixItems:
2002+
- type: string
2003+
items:
2004+
anyOf:
2005+
- type: string
2006+
- $comment: To allow binary, this must always pass
2007+
prefixEncoding:
2008+
- contentType: text/html
2009+
headers:
2010+
Content-ID:
2011+
$ref: '#/components/headers/RFC2557ContentId'
2012+
Content-Location:
2013+
$ref: '#/components/headers/RFC2557ContentLocation'
2014+
itemEncoding:
2015+
contentType: text/html, text/css, text/javascript
2016+
headers:
2017+
Content-ID:
2018+
$ref: '#/components/headers/RFC2557ContentId'
2019+
Content-Location:
2020+
$ref: '#/components/headers/RFC2557ContentLocation'
19962021
```
19972022

1998-
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.
1999-
20002023
###### Example: Streaming Multipart
20012024

20022025
This example assumes a device that takes large sets of pictures and streams them to the caller.
@@ -4138,6 +4161,11 @@ The rules for connecting a [Security Requirement Object](#security-requirement-o
41384161

41394162
OpenAPI Descriptions may contain references to external resources that may be dereferenced automatically by consuming tools. External resources may be hosted on different domains that may be untrusted.
41404163

4164+
### Detecting Media Types
4165+
4166+
Scenarios such as those documented under [Example: Ordered Multipart With Required Header](#example-ordered-multipart-with-required-header) can require an implementation to test whether data matches one of several different media types.
4167+
Each media type has its own security considerations to be taken into accound during such testing.
4168+
41414169
### Handling Reference Cycles
41424170

41434171
References in an OpenAPI Description may cause a cycle. Tooling must detect and handle cycles to prevent resource exhaustion.

0 commit comments

Comments
 (0)