Skip to content

Commit 52c9d88

Browse files
authored
Merge pull request #3880 from handrews/disc-backport-304
Backport (3.0.4) of merge resolution from #3846
2 parents 102fba6 + 1308aa8 commit 52c9d88

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

versions/3.0.4.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ When parsing an OAD, JSON or YAML objects are parsed into specific Objects (such
163163

164164
If the same JSON/YAML object is parsed multiple times and the respective contexts require it to be parsed as _different_ Object types, the resulting behavior is _implementation defined_, and MAY be treated as an error if detected. An example would be referencing an empty Schema Object under `#/components/schemas` where a Path Item Object is expected, as an empty object is valid for both types. For maximum interoperability, it is RECOMMENDED that OpenAPI Description authors avoid such scenarios.
165165

166+
#### <a name="resolvingImplicitConnections"></a>Resolving Implicit Connections
167+
166168
### <a name="dataTypes"></a>Data Types
167169

168170
Primitive data types in the OAS are based on the types supported by the [JSON Schema Specification Wright Draft 00](https://tools.ietf.org/html/draft-wright-json-schema-00#section-4.2).
@@ -2647,7 +2649,7 @@ components:
26472649
]
26482650
},
26492651
"Cat": {
2650-
"description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.",
2652+
"description": "A representation of a cat. Note that `Cat` will be used as the discriminating value.",
26512653
"allOf": [
26522654
{
26532655
"$ref": "#/components/schemas/Pet"
@@ -2674,7 +2676,7 @@ components:
26742676
]
26752677
},
26762678
"Dog": {
2677-
"description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.",
2679+
"description": "A representation of a dog. Note that `Dog` will be used as the discriminating value.",
26782680
"allOf": [
26792681
{
26802682
"$ref": "#/components/schemas/Pet"
@@ -2716,7 +2718,7 @@ components:
27162718
required:
27172719
- name
27182720
- petType
2719-
Cat: # "Cat" will be used as the discriminator value
2721+
Cat: # "Cat" will be used as the discriminating value
27202722
description: A representation of a cat
27212723
allOf:
27222724
- $ref: '#/components/schemas/Pet'
@@ -2732,7 +2734,7 @@ components:
27322734
- aggressive
27332735
required:
27342736
- huntingSkill
2735-
Dog: # "Dog" will be used as the discriminator value
2737+
Dog: # "Dog" will be used as the discriminating value
27362738
description: A representation of a dog
27372739
allOf:
27382740
- $ref: '#/components/schemas/Pet'
@@ -2750,12 +2752,14 @@ components:
27502752
27512753
#### <a name="discriminatorObject"></a>Discriminator Object
27522754
2753-
When request bodies or response payloads may be one of a number of different schemas, a Discriminator Object can be used to aid in serialization, deserialization, and validation by implicitly or explicitly associating the possible values of a named property with alternative schemas.
2755+
When request bodies or response payloads may be one of a number of different schemas, a Discriminator Object gives a hint about the expected schema of the document.
2756+
This hint can be used to aid in serialization, deserialization, and validation.
2757+
The Discriminator Object does this by implicitly or explicitly associating the possible values of a named property with alternative schemas.
27542758
27552759
##### Fixed Fields
27562760
Field Name | Type | Description
27572761
---|:---:|---
2758-
<a name="propertyName"></a>propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value.
2762+
<a name="propertyName"></a>propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminating value. This property SHOULD be required in the payload schema, as the behavior when the property is absent is undefined.
27592763
<a name="discriminatorMapping"></a> mapping | Map[`string`, `string`] | An object to hold mappings between payload values and schema names or URI references.
27602764

27612765
##### Conditions for Using the Discriminator Object
@@ -2779,6 +2783,8 @@ However, the exact nature of such conversions are implementation-defined.
27792783

27802784
##### <a name="discriminatorExamples"></a>Examples
27812785

2786+
For these examples, assume all schemas are in the entry OpenAPI document; for handling of `discriminator` in referenced documents see [Resolving Implicit Connections](#resolvingImplicitConnections).
2787+
27822788
In OAS 3.0, a response payload MAY be described to be exactly one of any number of types:
27832789

27842790
```yaml
@@ -2829,7 +2835,7 @@ MyResponseType:
28292835
monster: https://gigantic-server.com/schemas/Monster/schema.json
28302836
```
28312837

2832-
Here the discriminator _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `Dog`. If the discriminator _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail.
2838+
Here the discriminating value of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `#/components/schemas/dog`. If the discriminating value does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail.
28332839

28342840
When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload.
28352841

0 commit comments

Comments
 (0)