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
@@ -3062,6 +3062,8 @@ When request bodies or response payloads may be one of a number of different sch
3062
3062
This hint can be used to aid in serialization, deserialization, and validation.
3063
3063
The Discriminator Object does this by implicitly or explicitly associating the possible values of a named property with alternative schemas.
3064
3064
3065
+
Note that `discriminator` MUST NOT change the validation outcome of the schema.
3066
+
3065
3067
##### Fixed Fields
3066
3068
Field Name | Type | Description
3067
3069
---|:---:|---
@@ -3070,11 +3072,16 @@ Field Name | Type | Description
3070
3072
3071
3073
##### Conditions for Using the Discriminator Object
3072
3074
The Discriminator Object is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`.
3075
+
3073
3076
In both the `oneOf` and `anyOf` use cases, where those keywords are adjacent to `discriminator`, all possible schemas MUST be listed explicitly.
3077
+
3074
3078
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.
3075
3079
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.
3076
3080
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.
3077
3081
3082
+
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.
3083
+
This is because `discriminator` cannot change the validation outcome, and no standard JSON Schema keyword connects the parent schema to the child schemas.
3084
+
3078
3085
The behavior of any configuration of `oneOf`, `anyOf`, `allOf` and `discriminator` that is not described above is undefined.
0 commit comments