You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This backports changes made to the Discriminator Object
in 3.1.1 and merges them with the changes made on this branch.
Note that the previouc changes incorporated reworked ideas from
@jdesrosiers regarding the ambiguous `mapping` syntax submitted
in the 3.1.1 changes but not accepted at that time due to
compatibility concerns. This commit merges in the parts of
that 3.1.1 change that were accepted.
For the same compatibility reasons, the MUST wording for
requiring the named discriminator property in the schema
was (regrettably) weakened to a "SHOULD but otherwise undefined",
as we have done for other problematic ambiguities.
Co-authored-by: Jason Desrosiers <[email protected]>
Copy file name to clipboardExpand all lines: versions/3.0.4.md
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,10 @@ When parsing an OAD, JSON or YAML objects are parsed into specific Objects (such
163
163
164
164
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.
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).
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.
2754
+
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.
2755
+
This hint can be used to aid in serialization, deserialization, and validation.
2756
+
The Discriminator Object does this by implicitly or explicitly associating the possible values of a named property with alternative schemas.
2751
2757
2752
2758
##### Fixed Fields
2753
2759
Field Name | Type | Description
2754
2760
---|:---:|---
2755
-
<a name="propertyName"></a>propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value.
2761
+
<a name="propertyName"></a>propertyName | `string` | **REQUIRED**. The name of the property in the payload that will hold the discriminator value. This property SHOULD be required in the payload schema, as the behavior when the property is absent is undefined.
2756
2762
<a name="discriminatorMapping"></a> mapping | Map[`string`, `string`] | An object to hold mappings between payload values and schema names or URI references.
2757
2763
2758
2764
##### Conditions for Using the Discriminator Object
@@ -2776,6 +2782,10 @@ However, the exact nature of such conversions are implementation-defined.
For these examples, assume all schemas are in the entry OpenAPI document; for handling of `discriminator` in referenced documents see [Resolving Implicit Connections](#resolvingImplicitConnections).
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.
2839
+
Here the discriminator property _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `#/components/schemas/dog`. If the discriminator property _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail.
2830
2840
2831
2841
When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload.
0 commit comments