title: How to use $ref in swagger file properly while working with swagger-ui-express and swagger-jsdoc
body: <p>I started to use swagger with <strong>swagger-ui-express</strong> and <strong>swagger-jsdoc</strong> to auto document my existing API, which is written with <em>nodejs</em> and express (like described here - <a href="http://www.acuriousanimal.com/2018/10/20/express-swagger-doc.html" rel="noreferrer">example</a>).</p>
  
  <p>I came across a problem when I tried to add a <code>$ref</code> to an existing <em>JSON Schema</em> file (that sits inside my project on the same directory as all my js files) on my annotation.</p>
  
  <p><a href="https://i.stack.imgur.com/GPON2.png" rel="noreferrer">My directory looks like this</a></p>
  
  <p>I tried to write the local path (<code>./schema.json</code>) and the absolute path, tried to use <code>#</code>, using many syntaxes and nothing worked.</p>
  
  <p>My annotation looks like this: </p>
  
  <pre><code>/**
   * @swagger
   * /testing:
   *    get:
   *      description: This should show the json schema
   *      responses:
   *          200:
   *              description: "successful operation"
   *              schema:
   *                 $ref: "./schema.json"
   */
  </code></pre>
  
  <p>I expected the swagger ui to show me the JSON schema in my request section by. I get the following error - </p>
  
  <pre><code>Resolver error at paths./testing.get.responses.200.schema.$ref
  Could not resolve reference: Tried to resolve a relative URL, without having a basePath. path: './schema.json' basePath: 'undefined'.
  </code></pre>
  
  <p>I looked the problem up online and couldn’t find any clear answer. I saw a solution that suggested I should put my schema on a server and access it with an URL address but I prefer not to do it on this point.</p>
  
  <p>Also, at some point, I saved the scheme in a variable and then put it in the <code>$ref</code> and it worked fine. The only problem was that the scheme included some inner refs to an element in the same file and <em>Swagger</em> couldn't resolve them.</p>
  
  <p>Is there a way to work properly with <code>$ref</code> in <strong>swagger-ui-express</strong>?</p>