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
Copy file name to clipboardExpand all lines: versions/3.0.4.md
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3026,6 +3026,8 @@ When request bodies or response payloads may be one of a number of different sch
3026
3026
This hint can be used to aid in serialization, deserialization, and validation.
3027
3027
The Discriminator Object does this by implicitly or explicitly associating the possible values of a named property with alternative schemas.
3028
3028
3029
+
Note that `discriminator` MUST NOT change the validation outcome of the schema.
3030
+
3029
3031
##### Fixed Fields
3030
3032
Field Name | Type | Description
3031
3033
---|:---:|---
@@ -3034,11 +3036,16 @@ Field Name | Type | Description
3034
3036
3035
3037
##### Conditions for Using the Discriminator Object
3036
3038
The Discriminator Object is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`.
3039
+
3037
3040
In both the `oneOf` and `anyOf` use cases, where those keywords are adjacent to `discriminator`, all possible schemas MUST be listed explicitly.
3041
+
3038
3042
To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas building on the parent schema via an `allOf` construct may be used as an alternate schema.
3039
3043
It is implementation-defined as to whether all named [Schema Objects](#schemaObject) under the [Components Object](#componentsObject), or only those that are otherwise directly referenced are searched for `allOf` references to the parent schema.
3040
3044
However, it is RECOMMENDED to search all named schemas in the Components Object because it is common with the `allOf` usage for other parts of the API to only directly reference the parent schema.
3041
3045
3046
+
The `allOf` form of `discriminator` is _only_ useful for non-validation use cases; validation with the parent schema with this form of `discriminator` _does not_ perform a search for child schemas or use them in validation in any way.
3047
+
This is because `discriminator` cannot change the validation outcome, and no standard JSON Schema keyword connects the parent schema to the child schemas.
3048
+
3042
3049
The behavior of any configuration of `oneOf`, `anyOf`, `allOf` and `discriminator` that is not described above is undefined.
0 commit comments