Forum Discussion

mukeshna's avatar
Occasional Visitor
6 years ago

Using $ref in open API spec 3.0 in swagger hub - Remote Reference

Hi All,


We are switching to open api spec 3.0 from 2.0 and the only real difficulty we are getting is to use $ref in 3.0 version. In version 2.0, it was so straightforward that we could define a different model definition file and defined all the model definition there. and could reference between those model definition files as well. 

Now with 3.0, we had to define components within APIs and now, if one API wants to use a component from another API, we are not able to do that. 

We could see the following snippet in the documentation but don't see a live example. Could someone please help us with a live example. Thanks


Remote Reference – $ref: 'document.json' Uses the whole document located on the same server and in the same location.

  • The element of the document located on the same server  $ref: 'document.json#/myElement'
  • The element of the document located in the parent folder  $ref: '../document.json#/myElement'
  • The element of the document located in another folder  $ref: '../another-folder/document.json#/myElement'


No RepliesBe the first to reply