/// <summary>
        /// Resolves any subschemas during resolution of a `$ref` during validation.
        /// </summary>
        /// <param name="pointer">A <see cref="JsonPointer"/> to the target schema.</param>
        /// <param name="baseUri">The current base URI.</param>
        /// <param name="supportedVersions">Indicates the root schema's supported versions.</param>
        /// <returns>The referenced schema, if it exists; otherwise null.</returns>
        public JsonSchema?ResolveSubschema(JsonPointer pointer, Uri baseUri, JsonSchemaVersion supportedVersions)
        {
            var first = pointer.FirstOrDefault();

            if (first == null)
            {
                return(null);
            }

            var keyword = this.FirstOrDefault(k => k.PropertyName == first);

            return(keyword?.ResolveSubschema(new JsonPointer(pointer.Skip(1)), baseUri, supportedVersions));
        }
예제 #2
0
        /// <summary>
        /// Resolves any subschemas during resolution of a `$ref` during validation.
        /// </summary>
        /// <param name="pointer">A <see cref="JsonPointer"/> to the target schema.</param>
        /// <param name="baseUri">The current base URI.</param>
        /// <returns>The referenced schema, if it exists; otherwise null.</returns>
        public JsonSchema ResolveSubschema(JsonPointer pointer, Uri baseUri)
        {
            var first = pointer.FirstOrDefault();

            if (first == null)
            {
                return(null);
            }

            if (!TryGetValue(first, out var schema))
            {
                return(null);
            }

            return(schema.ResolveSubschema(new JsonPointer(pointer.Skip(1)), baseUri));
        }
예제 #3
0
        /// <summary>
        /// Resolves any subschemas during resolution of a <code>$ref</code> during validation.
        /// </summary>
        /// <param name="pointer">A <see cref="JsonPointer"/> to the target schema.</param>
        /// <param name="baseUri">The current base URI.</param>
        /// <returns>The referenced schema, if it exists; otherwise null.</returns>
        public JsonSchema ResolveSubschema(JsonPointer pointer, Uri baseUri)
        {
            var first = pointer.FirstOrDefault();

            if (first == null)
            {
                return(null);
            }

            if (!int.TryParse(first, out var index) || index < 0 || index >= Count)
            {
                return(null);
            }

            return(this[index].ResolveSubschema(new JsonPointer(pointer.Skip(1)), baseUri));
        }