public void ReferenceToNestedSchemaWithIdInResolvedSchema_Root() { JSchema nested = new JSchema(); nested.Id = new Uri("nested.json", UriKind.RelativeOrAbsolute); nested.Type = JSchemaType.String; JSchema root = new JSchema { Id = new Uri("http://test.test"), Items = { nested } }; string json = @"{""$ref"":""http://test.test/nested.json""}"; NestedPreloadedResolver resolver = new NestedPreloadedResolver(); resolver.Add(root.Id, root.ToString()); JSchemaReader schemaReader = new JSchemaReader(resolver); JSchema schema = schemaReader.ReadRoot(new JsonTextReader(new StringReader(json))); Assert.AreEqual(new Uri("nested.json", UriKind.RelativeOrAbsolute), schema.Id); Assert.AreEqual(JSchemaType.String, schema.Type); }
public void ReferenceToNestedSchemaWithIdInResolvedSchema_ExtensionData() { JSchema nested = new JSchema(); nested.Id = new Uri("nested.json", UriKind.RelativeOrAbsolute); JSchema root = new JSchema { Id = new Uri("http://test.test"), ExtensionData = { { "nested", nested } } }; string rootJson = root.ToString(); string json = @"{ ""type"":[""array""], ""items"":{""$ref"":""http://test.test/nested.json""} }"; NestedPreloadedResolver resolver = new NestedPreloadedResolver(); resolver.Add(root.Id, rootJson); JSchemaReader schemaReader = new JSchemaReader(resolver); JSchema schema = schemaReader.ReadRoot(new JsonTextReader(new StringReader(json))); Assert.AreEqual(new Uri("nested.json", UriKind.RelativeOrAbsolute), schema.Items[0].Id); Assert.AreEqual(nested, schema.Items[0]); }