Skip to content

Commit 8d115b7

Browse files
author
Ron
authored
Merge pull request OAI#1209 from OAI/multipart-changes
multipart clarifications
2 parents 1b57df4 + f854739 commit 8d115b7

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

versions/3.0.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ Field Name | Type | Description
13511351
<a name="mediaTypeSchema"></a>schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the request body.
13521352
<a name="mediaTypeExample"></a>example | Any | Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The `example` object is mutually exclusive of the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema.
13531353
<a name="mediaTypeExamples"></a>examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` object is mutually exclusive of the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema.
1354-
<a name="mediaTypeEncoding"></a>encoding | Map[`string`, [Encoding Object](#encodingObject)] | A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHOULD only apply to `requestBody` objects when the content type is `multipart`.
1354+
<a name="mediaTypeEncoding"></a>encoding | Map[`string`, [Encoding Object](#encodingObject)] | A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to `requestBody` objects when the media type is `multipart` or `application/x-www-form-urlencoded`.
13551355

13561356
This object can be extended with [Specification Extensions](#specificationExtensions).
13571357

@@ -1420,8 +1420,7 @@ application/json:
14201420

14211421
##### Considerations for File Uploads
14221422

1423-
In contrast with the 2.0 specification, `file` input/output content in OpenAPI is
1424-
described with the same semantics as any other schema type. Specifically:
1423+
In contrast with the 2.0 specification, `file` input/output content in OpenAPI is described with the same semantics as any other schema type. Specifically:
14251424

14261425
```yaml
14271426
# content transferred with base64 encoding
@@ -1463,6 +1462,23 @@ requestBody:
14631462
format: binary
14641463
```
14651464
1465+
To upload multiple files, a `multipart` media type MUST be used:
1466+
1467+
```yaml
1468+
requestBody:
1469+
content:
1470+
multipart/form-data:
1471+
schema:
1472+
properties:
1473+
# The property name 'file' will be used for all files.
1474+
file:
1475+
type: array
1476+
items:
1477+
type: string
1478+
format: binary
1479+
1480+
```
1481+
14661482
##### Support for x-www-form-urlencoded Request Bodies
14671483

14681484
To submit content using form url encoding via [RFC1866](https://tools.ietf.org/html/rfc1866), the following
@@ -1471,7 +1487,7 @@ definition may be used:
14711487
```yaml
14721488
requestBody:
14731489
content:
1474-
x-www-form-urlencoded:
1490+
application/x-www-form-urlencoded:
14751491
schema:
14761492
type: object
14771493
properties:
@@ -1486,13 +1502,13 @@ requestBody:
14861502

14871503
In this example, the contents in the `requestBody` MUST be stringified per [RFC1866](https://tools.ietf.org/html/rfc1866/) when passed to the server. In addition, the `address` field complex object will be stringified.
14881504

1489-
When passing complex objects in the `x-www-form-urlencoded` content type, the default serialization strategy of such properties is described in the `parameterContent` section as `form`.
1505+
When passing complex objects in the `application/x-www-form-urlencoded` content type, the default serialization strategy of such properties is described in the [`Encoding Object`](#encodingObject)'s [`style`](#encodingStyle) property as `form`.
14901506

14911507
##### Special Considerations for `multipart` Content
14921508

14931509
It is common to use `multipart/form-data` as a `Content-Type` when transferring request bodies to operations. In contrast to 2.0, a `schema` is REQUIRED to define the input parameters to the operation when using `multipart` content. This supports complex structures as well as supporting mechanisms for multiple file uploads.
14941510

1495-
When passing in `multipart` types, boundaries MAY be used to separate sections of the content being transferred — thus, the following default `Content-Type`s are defined for `multipart/*`:
1511+
When passing in `multipart` types, boundaries MAY be used to separate sections of the content being transferred — thus, the following default `Content-Type`s are defined for `multipart`:
14961512

14971513
* If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain`
14981514
* If the property is complex, or an array of complex values, the default Content-Type is `application/json`
@@ -1531,7 +1547,7 @@ requestBody:
15311547
type: '#/components/schemas/Address'
15321548
```
15331549
1534-
An `encoding` attribute is introduced to give you control over the serialization of parts of `multipart` request bodies. This attribute is _only_ applicable to `multipart/*` and `x-www-form-urlencoded` request bodies.
1550+
An `encoding` attribute is introduced to give you control over the serialization of parts of `multipart` request bodies. This attribute is _only_ applicable to `multipart` and `application/x-www-form-urlencoded` request bodies.
15351551

15361552
#### <a name="encodingObject"></a>Encoding Object
15371553

@@ -1541,10 +1557,10 @@ A single encoding definition applied to a single schema property.
15411557
Field Name | Type | Description
15421558
---|:---:|---
15431559
<a name="encodingContentType"></a>contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type: for `string` with `format` being `binary` – `application/octet-stream`; for other primitive types – `text/plain`; for `object` - `application/json`; for `array` – the default is defined based on the inner type.
1544-
<a name="encodingHeaders"></a>headers | Map[`string`, [Header Object](#headerObject)] | A string map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section.
1545-
<a name="encodingStyle"></a>style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values.
1546-
<a name="encodingExplode"></a>explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`.
1547-
<a name="encodingAllowReserved"></a>allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`.
1560+
<a name="encodingHeaders"></a>headers | Map[`string`, [Header Object](#headerObject)] | A string map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`.
1561+
<a name="encodingStyle"></a>style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
1562+
<a name="encodingExplode"></a>explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
1563+
<a name="encodingAllowReserved"></a>allowReserved | `boolean` | Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
15481564

15491565
This object can be extended with [Specification Extensions](#specificationExtensions).
15501566

0 commit comments

Comments
 (0)