You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently I am not aware of such feature. You should always provide the discriminator field. You could write a getter on your plain object, which would return the type based on your logic.
But I think it is always cleaner to be explicit and give it a type if it means a different thing, but that is a personal preference.
I have an array of contributors on an
author
, and other similar, properties.I would like to be able to discriminate between
Organization
andPerson
Contributors, without having to adding a common property to the JSON.Here's the code:
... and then, on a
Reference
class:And it all works, except I'd rather not add the "type" property, since I already know how to distinguish them based on their properties.
This particular model is likely to be edited by humans, so I want to keep the JSON schema I export from it as clean as possible.
So is there a way to have my cake and eat it too?
Or alternately, have a default mapping, if the
type
property isn't there?The text was updated successfully, but these errors were encountered: