Hi fellow TMForum members,
I have a couple of questions regarding creating of the new resources. According to spec, a resource can either be Logical or Physical. Apart from common properties, logical resource additionally has a Value property, while physical resource has ManufactureDate, PowerState, SerialNumber and VersionNumber. The model used for POST operation, Resource_Create, however, doesn't have any of the specific properties, only the common ones, so if we were to POST resource with PowerState property, it would be lost during deserialization.
Thanks in advance,
The discriminator to be used in this case is @type . Indeed in v5 APIs @type becomes a mandatory property since it is used explicitly as discriminator.
You are correct that there is a challenge here, it is apparent also in PaymentMethod API and other places where we define operations at base-class level.
As far as I understand, the idea is that you use the POST operation defined on the base class, but you nevertheless pass in a payload that matches the subclass schema. But I don't know exactly how code generators treat this situation.
Hey Jonathan, thanks for the response!
The thing is, it's a bit challenging to use @type as the discriminator here, at least when we look at sample payloads in the spec. The @type there is set to MSISDN, or Equipment, while @baseType in this case is set to LogicalResource or PhysicalResource.
In TMF720, we have a couple of nice examples of inheritance, i.e. EmailMedium and PhoneMedium as DigitalIdentityContactMedium specializations. Once we set @type as discriminator here, code generators play really nicely and generate the proper inheritance model. With this approach JSON payloads are deserialized in proper subclass models. Without the inheritance setup, base models would have to have all the properties, from all the subclasses (like RefOrValue entities do), which is obviously not the case with Resource, thus any extra data is lost during the deserialization.
I guess we will have to stick to some custom deserialization workaround for the time being.
Do you know if there is any v5 release roadmap available?
Thanks a lot!