Skip to content

Commit 45d844c

Browse files
authored
Merge pull request #4728 from handrews/mt-e-components
2 parents 00dbb5d + ec1e510 commit 45d844c

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

src/oas.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ All objects defined within the Components Object will have no effect on the API
633633
| <a name="components-links"></a> links | Map[`string`, [Link Object](#link-object) \| [Reference Object](#reference-object)] | An object to hold reusable [Link Objects](#link-object). |
634634
| <a name="components-callbacks"></a> callbacks | Map[`string`, [Callback Object](#callback-object) \| [Reference Object](#reference-object)] | An object to hold reusable [Callback Objects](#callback-object). |
635635
| <a name="components-path-items"></a> pathItems | Map[`string`, [Path Item Object](#path-item-object)] | An object to hold reusable [Path Item Objects](#path-item-object). |
636+
| <a name="components-media-types"></a> mediaTypes | Map[`string`, [Media Type Object](#media-type-object) \| [Reference Object](#reference-object)] | An object to hold reusable [Media Type Objects](#media-type-object). |
636637

637638
This object MAY be extended with [Specification Extensions](#specification-extensions).
638639

@@ -1014,7 +1015,7 @@ For use with `in: "querystring"` and `application/x-www-form-urlencoded`, see [E
10141015

10151016
| Field Name | Type | Description |
10161017
| ---- | :----: | ---- |
1017-
| <a name="parameter-content"></a>content | Map[`string`, [Media Type Object](#media-type-object)] | A map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry. |
1018+
| <a name="parameter-content"></a>content | Map[`string`, [Media Type Object](#media-type-object) \| [Reference Object](#reference-object)] | A map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry. |
10181019

10191020
##### Style Values
10201021

@@ -1204,7 +1205,7 @@ Describes a single request body.
12041205
| Field Name | Type | Description |
12051206
| ---- | :----: | ---- |
12061207
| <a name="request-body-description"></a>description | `string` | A brief description of the request body. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. |
1207-
| <a name="request-body-content"></a>content | Map[`string`, [Media Type Object](#media-type-object)] | **REQUIRED**. The content of the request body. The key is a media type or [media type range](https://www.rfc-editor.org/rfc/rfc9110.html#appendix-A) and the value describes it. The map SHOULD have at least one entry; if it does not, the behavior is implementation-defined. For requests that match multiple keys, only the most specific key is applicable. e.g. `"text/plain"` overrides `"text/*"` |
1208+
| <a name="request-body-content"></a>content | Map[`string`, [Media Type Object](#media-type-object) \| [Reference Object](#reference-object)] | **REQUIRED**. The content of the request body. The key is a media type or [media type range](https://www.rfc-editor.org/rfc/rfc9110.html#appendix-A) and the value describes it. The map SHOULD have at least one entry; if it does not, the behavior is implementation-defined. For requests that match multiple keys, only the most specific key is applicable. e.g. `"text/plain"` overrides `"text/*"` |
12081209
| <a name="request-body-required"></a>required | `boolean` | Determines if the request body is required in the request. Defaults to `false`. |
12091210

12101211
This object MAY be extended with [Specification Extensions](#specification-extensions).
@@ -1944,7 +1945,7 @@ Describes a single response from an API operation, including design-time, static
19441945
| <a name="response-summary"></a>summary | `string` | A short summary of the meaning of the response. |
19451946
| <a name="response-description"></a>description | `string` | A description of the response. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. |
19461947
| <a name="response-headers"></a>headers | Map[`string`, [Header Object](#header-object) \| [Reference Object](#reference-object)] | Maps a header name to its definition. [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#section-5.1) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored. |
1947-
| <a name="response-content"></a>content | Map[`string`, [Media Type Object](#media-type-object)] | A map containing descriptions of potential response payloads. The key is a media type or [media type range](https://www.rfc-editor.org/rfc/rfc9110.html#appendix-A) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. `"text/plain"` overrides `"text/*"` |
1948+
| <a name="response-content"></a>content | Map[`string`, [Media Type Object](#media-type-object) \| [Reference Object](#reference-object)] | A map containing descriptions of potential response payloads. The key is a media type or [media type range](https://www.rfc-editor.org/rfc/rfc9110.html#appendix-A) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. `"text/plain"` overrides `"text/*"` |
19481949
| <a name="response-links"></a>links | Map[`string`, [Link Object](#link-object) \| [Reference Object](#reference-object)] | A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](#components-object). |
19491950

19501951
This object MAY be extended with [Specification Extensions](#specification-extensions).
@@ -2445,7 +2446,7 @@ Using `content` with a `text/plain` media type is RECOMMENDED for headers where
24452446

24462447
| Field Name | Type | Description |
24472448
| ---- | :----: | ---- |
2448-
| <a name="header-content"></a>content | Map[`string`, [Media Type Object](#media-type-object)] | A map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry. |
2449+
| <a name="header-content"></a>content | Map[`string`, [Media Type Object](#media-type-object) \| [Reference Object](#reference-object)] | A map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry. |
24492450

24502451
##### Modeling Link Headers
24512452

src/schemas/validation/schema.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ $defs:
199199
type: object
200200
additionalProperties:
201201
$ref: '#/$defs/path-item'
202+
mediaTypes:
203+
type: object
204+
additionalProperties:
205+
$ref: '#/$defs/media-type-or-reference'
202206
patternProperties:
203-
'^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$':
207+
'^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems|mediaTypes)$':
204208
$comment: Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected
205209
propertyNames:
206210
pattern: '^[a-zA-Z0-9._-]+$'
@@ -517,14 +521,16 @@ $defs:
517521
$comment: https://spec.openapis.org/oas/v3.2#fixed-fields-10
518522
type: object
519523
additionalProperties:
520-
$ref: '#/$defs/media-type'
524+
$ref: '#/$defs/media-type-or-reference'
521525
propertyNames:
522526
format: media-range
523527

524528
media-type:
525529
$comment: https://spec.openapis.org/oas/v3.2#media-type-object
526530
type: object
527531
properties:
532+
description:
533+
type: string
528534
schema:
529535
$dynamicRef: '#meta'
530536
itemSchema:
@@ -538,6 +544,16 @@ $defs:
538544
- $ref: '#/$defs/examples'
539545
unevaluatedProperties: false
540546

547+
media-type-or-reference:
548+
if:
549+
type: object
550+
required:
551+
- $ref
552+
then:
553+
$ref: '#/$defs/reference'
554+
else:
555+
$ref: '#/$defs/media-type'
556+
541557
encoding:
542558
$comment: https://spec.openapis.org/oas/v3.2#encoding-object
543559
type: object

tests/schema/pass/media-type-examples.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ openapi: 3.2.0
33
info:
44
title: API
55
version: 1.0.0
6+
components:
7+
mediaTypes:
8+
StreamingPets:
9+
description: |
10+
Streaming sequence of JSON pet representations,
11+
suitable for use with any of the streaming JSON
12+
media types.
13+
itemSchema:
14+
$ref: '#components/schemas/Pet'
615
paths:
716
/something:
817
put:
@@ -31,8 +40,9 @@ paths:
3140
frog:
3241
$ref: '#/components/examples/frog-example'
3342
application/jsonl:
34-
itemSchema:
35-
$ref: '#components/schemas/Pet'
43+
$ref: '#/components/mediaTypes/StreamingPets'
44+
application/x-ndjson:
45+
$ref: '#/components/mediaTypes/StreamingPets'
3646
application/xml:
3747
schema:
3848
type: object

0 commit comments

Comments
 (0)