Skip to main content

no-redundant-model

Overview

This rule belongs to the apimatic-preliminary-linting ruleset and states that:

To get a good quality output, it is recommended to avoid redundant models. A redundant model can be one which has exactly the same properties as another model or which is a subset of another model so that it can be easily replaced by its superset model instead.

PropertyValue
EnabledYes
Maximum SeverityInformation
MessagePossible redundant models found.
CodeAPIMATICPRE_L106
TypeLinting
Rule SystemSemantic
Broad CategoryTypes/Models
Products ImpactedCode Generation, Developer Experience Portal, API Transformer
Tagspreliminary checks linting apimatic redundant model type custom type complex model global models

Suggested Fixes

  • If the models are indeed redundant, keep one and update references of all other models to use this one chosen model instead. Then, once its safe to do so, remove the extra models.
  • If a model is a subset of another model, you may want to review if keeping only the superset model would make more sense. If yes, remove the subset model and update all its references to use the superset model instead.
  • If a model is a subset of another model, you can choose to make it a base type of the superset model and then remove the repeating fields from the superset model. Use this option only if the models do imply a hierarchy in your API's context.

For More Information