Skip to content

Commit

Permalink
Discriminator: Improve final example
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jdesrosiers committed Jun 12, 2021
1 parent 9322b73 commit f009144
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion versions/3.1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2777,6 +2777,11 @@ For example:
```yaml
components:
schemas:
MyResponseType:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
- $ref: '#/components/schemas/Lizard'
Pet:
type: object
required:
Expand Down Expand Up @@ -2814,7 +2819,12 @@ components:
type: boolean
```
a payload like this:
The `MyResponseType` schema will use the discriminator defined by the `Pet`
schema because it is part of the `Cat`, `Dog`, and `Lizard` schemas in the
`oneOf`. The behavior if not all schemas define a `discriminator` and they are
not all the same is undefined.

Validated against the `MyResponseType` schema, a payload like this:

```json
{
Expand Down

0 comments on commit f009144

Please sign in to comment.