I am defining common schemas for Web services and I want to import them in the components/schema section of the specification. I want to create a canonical data model that is common across multiple services to avoid redefining similar objects in each service definition.
Is there a way to do this? Is there a similar mechanism to what XSD does with its import tag?
To expand on Helen's answer for those landing here from Google, if Pet.yaml is not a plain object but has several objects like this:
components:
schemas:
pet:
type: object
properties:
(...)
You can refer to it like this:
$ref: './common/Pet.yaml#/components/schemas/pet'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With