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.1.1.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2346,7 +2346,7 @@ The OpenAPI Specification allows combining and extending model definitions using
2346
2346
2347
2347
While composition offers model extensibility, it does not imply a hierarchy between the models.
2348
2348
To support polymorphism, the OpenAPI Specification adds the `discriminator` keyword.
2349
-
When used, the `discriminator` will indicate the name of the property that hints which schema definition is expected to validate the structure of the model.
2349
+
When used, the `discriminator` indicates the name of the property that hints which schema definition is expected to validate the structure of the model.
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` keyword is used to inform the consumer of the document which of the alternatives is expected or preferred.
2696
+
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. It can be used to aid in serialization, deserialization, and validation.
2697
2697
2698
2698
`discriminator`uses a schema's "name" to automatically map a property value to
2699
2699
a schema. The schema's "name" is the property name used when declaring the
@@ -2726,7 +2726,7 @@ MyResponseType:
2726
2726
- $ref: '#/components/schemas/Lizard'
2727
2727
```
2728
2728
2729
-
which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. Evaluating a `oneOf` can be a costly operation, so `discriminator` MAY be used as a "hint" to improve the efficiency of selection of the matching schema. The `discriminator` keyword cannot change the validation result of the `oneOf`, it can only help make the evaluation more efficient and provide better error messaging. We can then describe exactly which field tells us which schema is expected to match the instance:
2729
+
which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. Evaluating a `oneOf` can be a costly operation, so `discriminator` MAY be used as a "hint" to improve the efficiency of selection of the matching schema. The `discriminator` keyword cannot change the validation result of the `oneOf`, it can only help make the evaluation more efficient and provide better error messaging. We can specify the exact field that tells us which schema is expected to match the instance:
2730
2730
2731
2731
```yaml
2732
2732
MyResponseType:
@@ -2747,7 +2747,7 @@ The expectation now is that a property with name `petType` _MUST_ be present in
2747
2747
}
2748
2748
```
2749
2749
2750
-
Will indicate that the `Cat` schema is the alternative that is expected to match this payload.
2750
+
Will indicate that the `Cat` schema is expected to match this payload.
2751
2751
2752
2752
In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used:
0 commit comments