Skip to content

Commit 95d78c8

Browse files
committed
multipart clarifications
1 parent d5db302 commit 95d78c8

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

versions/3.0.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ Field Name | Type | Description
12981298
<a name="mediaTypeSchema"></a>schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the request body.
12991299
<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.
13001300
<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.
1301-
<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`.
1301+
<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 content type is `multipart` or `x-www-form-urlencoded`.
13021302

13031303
This object can be extended with [Specification Extensions](#specificationExtensions).
13041304

@@ -1367,8 +1367,7 @@ application/json:
13671367

13681368
##### Considerations for File Uploads
13691369

1370-
In contrast with the 2.0 specification, `file` input/output content in OpenAPI is
1371-
described with the same semantics as any other schema type. Specifically:
1370+
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:
13721371

13731372
```yaml
13741373
# content transferred with base64 encoding
@@ -1410,6 +1409,23 @@ requestBody:
14101409
format: binary
14111410
```
14121411
1412+
To upload multiple files, a `multipart` media type MUST be used:
1413+
1414+
```yaml
1415+
requestBody:
1416+
content:
1417+
multipart/form-data:
1418+
schema:
1419+
properties:
1420+
# The property name 'file' will be used for all files.
1421+
file:
1422+
type: array
1423+
items:
1424+
type: string
1425+
format: binary
1426+
1427+
```
1428+
14131429
##### Support for x-www-form-urlencoded Request Bodies
14141430

14151431
To submit content using form url encoding via [RFC1866](https://tools.ietf.org/html/rfc1866), the following
@@ -1433,7 +1449,7 @@ requestBody:
14331449

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

1436-
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`.
1452+
When passing complex objects in the `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`.
14371453

14381454
##### Special Considerations for `multipart` Content
14391455

@@ -1488,10 +1504,10 @@ A single encoding definition applied to a single schema property.
14881504
Field Name | Type | Description
14891505
---|:---:|---
14901506
<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.
1491-
<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.
1492-
<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.
1493-
<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`.
1494-
<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`.
1507+
<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`.
1508+
<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 `x-www-form-urlencoded`.
1509+
<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 `x-www-form-urlencoded`.
1510+
<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 `x-www-form-urlencoded`.
14951511

14961512
This object can be extended with [Specification Extensions](#specificationExtensions).
14971513

0 commit comments

Comments
 (0)