-Change reading schema references to ignore additional content after the $ref property

This commit is contained in:
JamesNK
2011-06-01 07:12:46 +00:00
parent 3997b601ff
commit 857d72530c
3 changed files with 11 additions and 3 deletions
@@ -97,7 +97,15 @@ namespace Newtonsoft.Json.Schema
if (propertyName == JsonSchemaConstants.ReferencePropertyName)
{
string id = (string)_reader.Value;
_reader.Read();
// skip to the end of the current object
while (_reader.Read() && _reader.TokenType != JsonToken.EndObject)
{
if (_reader.TokenType == JsonToken.StartObject)
throw new Exception("Found StartObject within the schema reference with the Id '{0}'"
.FormatWith(CultureInfo.InvariantCulture, id));
}
JsonSchema referencedSchema = _resolver.GetSchema(id);
if (referencedSchema == null)
throw new Exception("Could not resolve schema reference for Id '{0}'.".FormatWith(CultureInfo.InvariantCulture, id));