Skip to content

Commit 1a7ea68

Browse files
author
Ron
authored
Merge pull request #1196 from krishahn/discriminator-object
edit Discriminator Object
2 parents 8d7ae8e + 5d0a96e commit 1a7ea68

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

versions/3.0.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,7 @@ components:
28572857
28582858
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. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it.
28592859

2860-
Note, when using the discriminator, _inline_ schemas will not be considered when using the discriminator.
2860+
When using the discriminator, _inline_ schemas will not be considered.
28612861

28622862
##### Fixed Fields
28632863
Field Name | Type | Description
@@ -2877,7 +2877,7 @@ MyResponseType:
28772877
- $ref: '#/components/schemas/Lizard'
28782878
```
28792879

2880-
which means the paylod _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use:
2880+
which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use:
28812881

28822882

28832883
```
@@ -2917,11 +2917,11 @@ MyResponseType:
29172917
monster: 'https://gigantic-server.com/schemas/Monster/schema.json'
29182918
```
29192919

2920-
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 a implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Note, mapping keys MUST be string values, but tooling MAY response values to strings for comparison.
2920+
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. Mapping keys MUST be string values, but tooling MAY map response values to strings for comparison.
29212921

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

2924-
In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas composing the parent schema in an `allOf` construct may be used as an alternate schema.
2924+
In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an `allOf` construct may be used as an alternate schema.
29252925

29262926
For example:
29272927

0 commit comments

Comments
 (0)