Hi Alen
Indeed, the file is generated that way - the source schema for ContactMedium does not have the discriminator.
The allOf in the class ContactMedium is only to add the properties from the Extensible schema to the specific contact medium properties (id, preferred, contactType, validFor).
The discriminator is added so that the subclasses will be included in the OAS file.
I'm not sure if your suggestion is "better", but I'm not a swagger/OAS expert so I'd leave it to others to express an opinion.
------------------------------
Jonathan Goldberg
Amdocs Management Limited
Any opinions and statements made by me on this forum are purely personal, and do not necessarily reflect the position of the TM Forum or my employer.
------------------------------
Original Message:
Sent: Apr 08, 2024 09:34
From: Alen Ruvic
Subject: OAS3 allOf composition in combination with discriminator
Is following maybe better:
------------------------------
Alen Ruvic
SES Astra S.A.
Original Message:
Sent: Apr 08, 2024 08:00
From: Alen Ruvic
Subject: OAS3 allOf composition in combination with discriminator
Hi,
How to understand (for example below ContactMedium schema object)?
allOf is used to achieve composition of the Model to avoid redundancy: object Extensible is referenced and enriched with local properties. But what is the role of the discriminator here?
oneOf/anyOf in combination with discriminator and a mandatory propertyName and mapping I understand. It is used to achieve Polymorphism. Is below a mistake or this is deliberately generated? ContactMedium is just one example, but this pattern exists in many other places.
------------------------------
Alen Ruvic
SES Astra S.A.
------------------------------