Skip to main content

Introducing Discriminator Configuration using the API Portal

· 2 min read

We have provided the Discriminator support via the API portal.

Details

Discriminator is used to differentiate between a parent model and the model to be inherited from the parent. A discriminator is a specific object in a schema used to inform the consumer of the API with an alternative schema based on the value associated with it.

We already support discriminator using our SDKs to determine which class object to deserialize the server response into. However, we have now provided support for discriminator in our API developer portal.

In this release, support is added in the API Code Playground to select the required model which populates the discriminator value automatically.

API Playground Model

The model documentation page has been updated to show complete information related to inheritance-based discriminator. Following changes have been made on the "Model" page:

  • Parent model shows all child types.
  • Discriminator field is shown with the value mapping for the field.
  • View the fields inherited from parent classes in accordance.
  • Model schema is improved to show a single schema for inherited models.

Discriminator field in model

Model page for discriminator

What is Inheritance Based Discriminator

The inheritance model deals with schemas that share common properties. Instead of defining these properties individually for each schema, a single model can be assigned as a combination of the common properties to avoid repetition. This process is defined as inheritance. Discriminator is the keyword that helps consumers discriminate an object type. The purpose of using a discriminator is to describe the objects distinctly as the discriminator explicitly declares which property can be inspected to determine the object type.