Forum Discussion

mnouwens's avatar
mnouwens
Occasional Visitor
5 years ago

Open Api Inheritance

I am defining and api in Open Api.

 

And this work ok. But now i am running into a problem.

 

ChildEvent:
type: object
discriminator:
propertyName: eventTypeCode
mapping:
product: 'ChildEventProduct'
sleep: 'ChildEventSleep'

This will generate the correct class But can i make it abstract and it will not generate the 2 sub classes.

 

ChildEventsForPeriodResult:
type: object
properties:
events:
type: array
items:
$ref: 'Events.yaml#/ChildEvent'

DirtyHolder:
type: object
properties:
sleep:
$ref: 'Events.yaml#/ChildEventSleep'
product:
$ref: 'Events.yaml#/ChildEventProduct'
ChildEvent:
type: object
# oneOf:
# - $ref: 'Events.yaml#/ChildEventSleep'
# - $ref: 'Events.yaml#/ChildEventProduct'
discriminator:
propertyName: eventTypeCode
mapping:
product: 'ChildEventProduct'
sleep: 'ChildEventSleep'

properties:
id:
type: integer
format: int64
startTime:
$ref: 'General.yaml#/DateNoTimeZone'
endTime:
$ref: 'General.yaml#/DateNoTimeZone'
roomId:
type: integer
format: int64
comment:
type: string
repeatingEventId:
type: integer
format: int64
childId:
type: integer
format: int64
dayCareReportId:
type: integer
format: int64
privateEvent:
type: boolean
default: false
importantEvent:
type: boolean
default: false
markForExport:
type: boolean
default: false
groupEventId:
type: integer
format: int64
eventCode:
type: integer
format: int32
partyId:
type: integer
format: int64
ChildEventProduct:
allOf:
- $ref: 'Events.yaml#/ChildEvent'
- type: object
properties:
productId:
type: integer
format: int64
ChildEventSleep:
allOf:
- $ref: 'Events.yaml#/ChildEvent'
- type: object
properties: {}

This is the complete yaml file. What is wrong with this. Dirst i thougt it was the generator but it alos fails when generating the andoid client

 

Can this be done?

 

No RepliesBe the first to reply