-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
allOf could be encoded in general case via "tupling" type with each other in new type:
components:
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
discriminator:
propertyName: pet_type
Dog: # "Dog" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Dog`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: boolean
breed:
type: string
Cat: # "Cat" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Cat`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
hunts:
type: boolean
age:
type: integercould be encoded like
interface IPet =
abstract pet_type: string
type Pet =
{ pet_type: string }
interface IPet with
member x.pet_type = x.pet_type
type Cat =
{ hunts: bool
age: int
pet_type: string }
interface IPet with
member x.pet_type = x.pet_type
type Dog =
{ bark: bool
breed: string
pet_type: string }
interface IPet with
member x.pet_type = x.pet_typeMetadata
Metadata
Assignees
Labels
No labels