Skip to content

Commit da3c386

Browse files
Apply suggestions from PR review
Co-authored-by: Ralf Handl <[email protected]>
1 parent c11fda7 commit da3c386

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/oas.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3488,7 +3488,7 @@ MyResponseType:
34883488
- $ref: '#/components/schemas/Lizard'
34893489
```
34903490

3491-
which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. Deserialization of a `oneOf` can be a costly operation, as it requires determining which schema matches the payload and thus should be used in deserialization. This problem also exists for `anyOf` schemas. A `discriminator` MAY be used as a "hint" to improve the efficiency of selection of the matching schema. The [Discriminator Object](#discriminator-object) cannot change the validation result of the `oneOf`, it can only help make the deserialization more efficient and provide better error messaging. We can specify the exact field that tells us which schema is expected to match the instance:
3491+
which means a valid payload has to match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. Deserialization of a `oneOf` can be a costly operation, as it requires determining which schema matches the payload and thus should be used in deserialization. This problem also exists for `anyOf` schemas. A `discriminator` can be used as a "hint" to improve the efficiency of selection of the matching schema. The [Discriminator Object](#discriminator-object) cannot change the validation result of the `oneOf`, it can only help make the deserialization more efficient and provide better error messaging. We can specify the exact field that tells us which schema is expected to match the instance:
34923492

34933493
```yaml
34943494
MyResponseType:
@@ -3511,7 +3511,7 @@ The expectation now is that a property with name `petType` _MUST_ be present in
35113511

35123512
will indicate that the `Cat` schema is expected to match this payload.
35133513

3514-
In scenarios where the value of the discriminating property does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used:
3514+
In scenarios where the value of the discriminating property does not match the schema name or implicit mapping is not possible, an optional `mapping` definition can be used:
35153515

35163516
```yaml
35173517
MyResponseType:
@@ -3531,7 +3531,7 @@ Here the discriminating value of `dog` will map to the schema `#/components/sche
35313531

35323532
When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity for serializers/deserializers where multiple schemas may satisfy a single payload.
35333533

3534-
When the discriminating property is defined as optional, the Discriminator Object MUST include a `defaultMapping` field that specifies a schema of the `anyOf` or `oneOf` is expected to validate the structure of the model when the discriminating property is not present in the payload. This allows the schema to still be validated correctly even if the discriminator property is missing.
3534+
When the discriminating property is defined as optional, the Discriminator Object has to include a `defaultMapping` field that specifies a schema of the `anyOf` or `oneOf` is expected to validate the structure of the model when the discriminating property is not present in the payload. This allows the schema to still be validated correctly even if the discriminator property is missing.
35353535

35363536
For example:
35373537

0 commit comments

Comments
 (0)