at-least-one-component-reference
Overview
This rule belongs to the openapi-v3-apimatic-linting
ruleset and states that:
A component that is defined globally using the 'components' root object property must be referenced at least once by any other object in the API specification document. Referencing is performed using $ref.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Warning |
Message | Component was defined but never used. |
Code | OPENAPI3APIMATIC_L150 |
Type | Linting |
Rule System | Semantic |
Broad Category | OpenAPI Components |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi apimatic semantic linting component reference $ref global |
Suggested Fixes
- Ensure that each globally defined component is referenced at least once in the API.
- A component can be referenced using $ref with a valid path that can begin with '#/components/'.
- If a schema 'Pet' is defined under #/components/schemas, there must exist an object in the document that references this schema using a path like #/components/schemas/Pet.
- The components section helps define reusable components. If a component definition is not expected to be used, it must be removed.