Forum Discussion

Bains's avatar
Bains
New Contributor
4 years ago

OAS3 Reference to external document schemas

Hi, In my root api document (openapi.yaml) file, I am trying to make a reference ($ref) to a schema in an external document that is located in a directory under the root folder (/products/Products.y...
  • Bains's avatar
    4 years ago

    I think i have worked it out.

     

    My original reference was as follows:

          $ref: '/products/Products.yaml#/components/schemas/CreateProduct'

     

    What I did was modify it as follows:

     

         $ref: 'product/Products.yaml#/components/schemas/CreateProduct'

     

    The culprit in this case was the leading slash ("/") before 'products/Products.yaml'.

    Strangely i was also able to remove the leading slash before component and it worked also as follows:

         $ref: 'product/Products.yaml#components/schemas/CreateProduct'