Skip to content

Commit edf8ed1

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 031aea8 commit edf8ed1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

versions/3.1.1.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -2777,6 +2777,11 @@ For example:
27772777
```yaml
27782778
components:
27792779
schemas:
2780+
MyResponseType:
2781+
oneOf:
2782+
- $ref: '#/components/schemas/Cat'
2783+
- $ref: '#/components/schemas/Dog'
2784+
- $ref: '#/components/schemas/Lizard'
27802785
Pet:
27812786
type: object
27822787
required:
@@ -2814,7 +2819,12 @@ components:
28142819
type: boolean
28152820
```
28162821
2817-
a payload like this:
2822+
The `MyResponseType` schema will use the discriminator defined by the `Pet`
2823+
schema because it is part of the `Cat`, `Dog`, and `Lizard` schemas in the
2824+
`oneOf`. The behavior if not all schemas define a `discriminator` and they are
2825+
not all the same is undefined.
2826+
2827+
Validated against the `MyResponseType` schema, a payload like this:
28182828

28192829
```json
28202830
{

0 commit comments

Comments
 (0)