resolvable-model-reference
Overview
This rule belongs to the swagger-v1-validation
ruleset and states that:
A model can be referenced using either the type
or $ref
properties in several Swagger v1 document entities like operations, parameters and model properties. When a model is referenced this way, it must be pre-defined with the same name or id in the root level models
section of the API Declaration/Resource Listing file.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Referenced model type could not be found. |
Code | SWAGGER1_V300 |
Type | Validation |
Rule System | Semantic |
Broad Category | Data Types |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | swagger1 swagger semantic validation name model $ref type data type |
Suggested Fixes
- Ensure that the root level
models
property is set in the document and is a non-empty object containing model definitions. - Ensure that the name used for referencing a model matches exactly with the key name or
id
of a model definition in the root levelmodels
property. Name is compared in a case-sensitive manner. - Ensure that the name has no typos.
- Ensure that the referenced model definition is a valid Model Object.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/1.2.md#527-model-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/1.2.md#526-models-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/1.2.md#433-data-type-fields
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/1.2.md#43-data-types
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/1.2.md
- https://docs.apimatic.io/rulesets/overview/