Usage of discriminators is already supported by our code generation engine. We are happy to announce that now support for using discriminators has also been added to Node.
- Discriminator is a field that is used to differentiate between a parent model and models that inherit from it.
- The response is deserialized into the parent model or one of its child classes by inspecting the discriminator field's value in the response.
- Using a discriminator field, you can build leaner models by not having to build unions of fields needed by a polymorphic response.
Please generate your SDK again if you want to use this feature.
Details Of Changes
The following changes have been made to the SDK:
- In Model files, the discriminator field will now be identified with a flag (in the mapping information of fields)
- A new function has been added to model files. It keeps track of discriminator values and their corresponding model class names.
- The mapping functions present in
ObjectMapperhave been updated to take into account the discriminator values (if present) and return the correctly deserialized instances.
- Some helper functions have been added to