Skip to content

Commit 19ea81c

Browse files
committed
Discriminator: Improve final example
This example was super confusing, which is mostly because it doesn't indicate which schema the payload examples are being applied to. So, I added the schema and an explanation of what is happening.
1 parent 314a756 commit 19ea81c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

versions/3.1.1.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,11 @@ For example:
27722772
```yaml
27732773
components:
27742774
schemas:
2775+
MyResponseType:
2776+
oneOf:
2777+
- $ref: '#/components/schemas/Cat'
2778+
- $ref: '#/components/schemas/Dog'
2779+
- $ref: '#/components/schemas/Lizard'
27752780
Pet:
27762781
type: object
27772782
required:
@@ -2809,7 +2814,12 @@ components:
28092814
type: boolean
28102815
```
28112816
2812-
a payload like this:
2817+
The `MyResponseType` schema will use the discriminator defined by the `Pet`
2818+
schema because it is part of the `Cat`, `Dog`, and `Lizard` schemas in the
2819+
`oneOf`. The behavior if not all schemas define a `discriminator` and they are
2820+
not all the same is undefined.
2821+
2822+
Validated against the `MyResponseType` schema, a payload like this:
28132823

28142824
```json
28152825
{

0 commit comments

Comments
 (0)