Skip to main content

no-inline-model-definition

Overview

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

It is recommended that a model definition is added globally with a unique name and then referenced throughout the API description with that name. Inline definitions of models with components are not recommended as the names of such models are generated from the components in which they are declared. This can result in duplicate names which are handled by appending a number at the end. This behavior can affect your output quality.

PropertyValue
EnabledYes
Maximum SeverityWarning
MessageInline model definitions found.
CodeAPIMATICPRE_L105
TypeLinting
Rule SystemSemantic
Broad CategoryTypes/Models
Products ImpactedCode Generation, Developer Experience Portal, API Transformer
Tagspreliminary checks linting apimatic inline model type custom type complex model global models

Suggested Fixes

  • Identify all locations in your API description file where models are declared inline. Then move all such inline model definitions to the global model definitions and assign a unique name to each of them. Then, update references of these models accordingly.
  • Rename the models using unique, short and meaningful names to avoid bad quality output.
  • Combine models that have similar properties to avoid redundant models in the output.

For More Information