title: How do I get Newtonsoft.Json.Schema to resolve a subschema?
body: <p>I'm trying to get Newtonsoft.Json.Schema to parse the schema at <a href="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceListing.json#" rel="nofollow">https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceListing.json#</a> but it's failing to parse the subschema referenced as resourceObject.json#. It correctly figures out the url should be <a href="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#" rel="nofollow">https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#</a> but fails to load it with this error: </p>
  
  <blockquote>
    <p>Could not resolve schema reference '<a href="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#" rel="nofollow">https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#</a>'. Path 'properties.apis.items', line 10, position 22.</p>
  </blockquote>
  
  <p>I validated both schemas using <a href="http://www.jsonschemavalidator.net/" rel="nofollow">http://www.jsonschemavalidator.net/</a> which seems to use the same library I'm using. I also used that site with my referenced schema (resourceListing.json) to validate what I'm trying to validate and it worked.</p>
  
  <p>I tried to load it myself using the JSchemaPreloadedResolver as suggested in <a href="http://www.newtonsoft.com/jsonschema/help/html/LoadingSchemas.htm" rel="nofollow">this documentation</a> but that results in the exact same error. Here's the code I used with RestSharp as my client library.</p>
  
  <pre><code>var dependencyResolver = new JSchemaPreloadedResolver();
  dependencyResolver.Add(
     new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#"),
     client.Get&lt;string&gt;("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#")
  );
  var schema = JSchema.Parse(client.Get&lt;string&gt;("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceListing.json#"), dependencyResolver);
  </code></pre>