-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
Are discriminator inheritable?
Given the following SpecA:
components:
schemas:
Pet:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
Reptile:
allOf:
- $ref: '#/components/schemas/Pet'
Lizard:
allOf:
- $ref: '#/components/schemas/Reptile'
- type: object
properties:
lovesRocks:
type: boolean
Do Reptile and Lizard contain the discriminator defined in Pet?
If discriminators are inheritable, then what is the correct interpretation of receiving payloads of type Reptile from the below specs?
SpecB (discriminator missing from Snake + Lizard)
components:
schemas:
Pet:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
Reptile:
allOf:
- $ref: '#/components/schemas/Pet'
oneOf:
- $ref: '#/components/schemas/Lizard'
- $ref: '#/components/schemas/Snake'
Lizard:
type: object
properties:
lovesRocks:
type: boolean
Snake:
type: object
properties:
hasLegs:
type: boolean
SpecC: (discriminator present in Snake + Lizard)
components:
schemas:
Pet:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
Reptile:
allOf:
- $ref: '#/components/schemas/Pet'
oneOf:
- $ref: '#/components/schemas/Lizard'
- $ref: '#/components/schemas/Snake'
Lizard:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
lovesRocks:
type: boolean
Snake:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
hasLegs:
type: boolean
Metadata
Metadata
Assignees
Labels
No labels