title: How to validate a JSON schema with nested references
body: <p>I have a JSON schema that references multiple schemas, using the '$ref' parameter whose schemas, in turn, reference other schemas. </p>
  
  <p>For eg.</p>
  
  <pre><code>{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "allOf": [
      {
        "$ref": "xyz.json"
      }
    ]
  }
  </code></pre>
  
  <p>where schema xyz.json is:</p>
  
  <pre><code>{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "id": { "type": "string",  "title": "Identifier"},
      "Xid": { "type": "object",  "$ref": "pqr.json", "title": "X Identifier"}
      }
  }
  </code></pre>
  
  <p>Just for the sake of 
  convenience, I've placed them all in a single directory and attempted to validate the schema using a library called <a href="https://epoberezkin.github.io/ajv/" rel="nofollow noreferrer">Ajv</a> but on compiling the schema I get the error: 
  <code>can't resolve reference #/event.json from id</code>. </p>
  
  <p>How can I possibly validate such a JSON schema? My goal is to create a single JavaScript object model for all the schemas. Thanks.</p>