Skip to main content

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.

PropertyValue
EnabledYes
Maximum SeverityWarning
MessageComponent was defined but never used.
CodeOPENAPI3APIMATIC_L150
TypeLinting
Rule SystemSemantic
Broad CategoryOpenAPI Components
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 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.

For More Information