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.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Warning |
Message | Inline model definitions found. |
Code | APIMATICPRE_L105 |
Type | Linting |
Rule System | Semantic |
Broad Category | Types/Models |
Products Impacted | Code Generation, Developer Experience Portal, API Transformer |
Tags | preliminary 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.