Example #1
0
        /// <summary>Deserializes a JSON string to a <see cref="JsonSchema"/>. </summary>
        /// <param name="data">The JSON string. </param>
        /// <param name="documentPath">The document path (URL or file path) for resolving relative document references.</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <returns>The JSON Schema.</returns>
        public static async Task <JsonSchema> FromJsonAsync(string data, string documentPath, CancellationToken cancellationToken = default)
        {
            var factory = JsonReferenceResolver.CreateJsonReferenceResolverFactory(new DefaultTypeNameGenerator());

            return(await FromJsonAsync(data, documentPath, factory, cancellationToken).ConfigureAwait(false));
        }
Example #2
0
        /// <summary>Loads a JSON Schema from a given URL (only available in .NET 4.x).</summary>
        /// <param name="url">The URL to the document.</param>
        /// <returns>The JSON Schema.</returns>
        /// <exception cref="NotSupportedException">The HttpClient.GetAsync API is not available on this platform.</exception>
        public static async Task <JsonSchema> FromUrlAsync(string url)
        {
            var factory = JsonReferenceResolver.CreateJsonReferenceResolverFactory(new DefaultTypeNameGenerator());

            return(await FromUrlAsync(url, factory).ConfigureAwait(false));
        }
Example #3
0
        /// <summary>Loads a JSON Schema from a given URL (only available in .NET 4.x).</summary>
        /// <param name="url">The URL to the document.</param>
        /// <returns>The JSON Schema.</returns>
        /// <exception cref="NotSupportedException">The HttpClient.GetAsync API is not available on this platform.</exception>
        public static async Task <JsonSchema4> FromUrlAsync(string url)
        {
            var factory = JsonReferenceResolver.CreateJsonReferenceResolverFactory(new JsonSchemaGeneratorSettings());

            return(await FromUrlAsync(url, factory).ConfigureAwait(false));
        }
Example #4
0
        /// <summary>Deserializes a JSON string to a <see cref="JsonSchema4"/>. </summary>
        /// <param name="data">The JSON string. </param>
        /// <param name="documentPath">The document path (URL or file path) for resolving relative document references.</param>
        /// <returns>The JSON Schema.</returns>
        public static async Task <JsonSchema4> FromJsonAsync(string data, string documentPath)
        {
            var factory = JsonReferenceResolver.CreateJsonReferenceResolverFactory(new JsonSchemaGeneratorSettings());

            return(await FromJsonAsync(data, documentPath, factory).ConfigureAwait(false));
        }
Example #5
0
 /// <summary>Loads a JSON Schema from a given file path (only available in .NET 4.x).</summary>
 /// <param name="filePath">The file path.</param>
 /// <returns>The JSON Schema.</returns>
 public static async Task<JsonSchema4> FromFileAsync(string filePath)
 {
     var factory = JsonReferenceResolver.CreateJsonReferenceResolverFactory(new JsonSchemaGeneratorSettings());
     return await FromFileAsync(filePath, factory).ConfigureAwait(false);
 }