valid-discriminator-field
Overview
This rule belongs to the apimatic-preliminary-validation
ruleset and states that:
If a discriminator is set for the model, a corresponding discriminator field should be part of the model fields. This discriminator field should be optional and of "String" type only. The name of the discriminator field must match with the name of the discriminator set in the model.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | The discriminator field defined in the model is invalid. |
Code | APIMATICPRE_V504 |
Type | Validation |
Rule System | Semantic |
Broad Category | Global Types/Models |
Products Impacted | Code Generation, Developer Experience Portal, API Transformer |
Tags | preliminary checks validation apimatic discriminator inheritance type custom type model complex model |
Suggested Fixes
- Make sure there is only one field named equal to the discriminator in the model and that it is optional. Remove all other conflicting fields.
- Make sure the discriminator field is string-typed. Other types (including enumerations) are not supported.