required-discriminator-field
Overview
This rule belongs to the apimatic-post-processing-validation ruleset and states that:
If a discriminator is specified for a model, the model must have a corresponding discriminator field/property defined in its fields. If it is found to be missing, a default discriminator field definition will be automatically added.
| Property | Value |
|---|---|
| Enabled | Yes |
| Maximum Severity | Warning |
| Message | Missing discriminator field/property definition has been auto-generated and added to the current type's fields/properties. |
| Code | APIMATICPOSTPROCESS_V403 |
| Type | Validation |
| Rule System | Semantic |
| Broad Category | Global Types/Models |
| Products Impacted | Code Generation, Developer Experience Portal, API Transformer |
| Tags | apimatic postprocessing validation discriminator field property type custom type model complex model |
Suggested Fixes
- Make sure that if you have a discriminator set for a model, then an explicit discriminator field/property definition is also added in the same model's fields/properties.
- The name of the discriminator property/field must exactly match the name of the discriminator set in the model/type definition.
- Only a string typed discriminator property/field is currently supported.