As we have seen, a field of abstract type can be of different type that inherits this abstract type

For example, an invoice can have a mean of payment which can be either a check, credit card or bank transfer.

Note: Remember to indicate a discriminator with a field and a different value for each type that extends an abstract type (this field with different values will be used as a discriminator in OpenAPI and AsyncAPI generations. They will also be used by the Akwatype xAdapt transformation engine when transforming examples)

type Invoice{
   num:String
   amount:Decimal
   meanOfPaiement:MeanOfPayment
}
abstract MeanOfPayment{ name:String bank:String type:String }
type CreditCard extends MeanOfPayment{ cardNumer:String expirationDate:Date securityCode:String
discriminator{
type:"01"
}
} type Check extends MeanOfPayment{ checkNumber:String checkingAccountNumber:String
discriminator{
type:"02"
}
}
type BankTransfert extends MeanOfPayment{ eban:String creditTransfertType:String creditTransferObject:String
discriminator{
type:"03"
}
}

Insofar, as the abstract type field can be of several types that inherit this abstract type, it is necessary to indicate a facade for each of them.

Akwatype allows to define a facade on an abstract type. For this special declaration the name of the abstract type on which the facade is defined

is followed by :: and, in parenthesis, the list of facades that we want to apply for each possible type.

If no facade is associated to the field for a given type (BankTransfer in our example) then the field can no longer be of this type.

This facade can then be applied to fields of this abstract type.

facade CreditCardOrCheckDTO on MeanOfPayment::(CreditCardDTO,CheckDTO)

facade
InvoiceDTO on Invoice{ num amount meanOfPaiement::CreditCardOrCheckDTO } facade CreditCardDTO on CreditCard{ type name cardNumer } facade CheckDTO on Check{ type name checkNumber }