object-can-be-a-reference
Overview
This rule belongs to the openapi-v3-standards-validation
ruleset and states that:
An OpenAPI object can be replaced by a Reference Object if the OpenAPI v3 Specification explicitly states that the value may be a reference. You can therefore, not use $ref in objects that do not allow replacement by a Reference Object.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | The current object value cannot be a Reference Object. |
Code | OPENAPI3STANDARDS_V310 |
Type | Validation |
Rule System | Semantic |
Broad Category | References |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi standards semantic validation reference json pointer ref $ref |
Suggested Fixes
- Remove $ref from the current object and define the referenced component directly in its place.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object
- https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03
- https://datatracker.ietf.org/doc/html/rfc3986
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-specification
- https://docs.apimatic.io/rulesets/overview/