/// <summary>
        /// Generates a schema from a CLR type.
        /// </summary>
        /// <param name="builder">The schema builder.</param>
        /// <param name="type">The type to generate.</param>
        /// <returns>The schema builder (for fluent syntax support).</returns>
        public static JsonSchemaBuilder FromType(this JsonSchemaBuilder builder, Type type)
        {
            var context = SchemaGenerationContextCache.Get(type, new List <Attribute>());

            context.Optimize();

            context.Apply(builder);

            return(builder);
        }
예제 #2
0
        /// <summary>
        /// Generates a schema from a CLR type.
        /// </summary>
        /// <param name="builder">The schema builder.</param>
        /// <param name="type">The type to generate.</param>
        /// <param name="configuration">The generator configuration.</param>
        /// <returns>The schema builder (for fluent syntax support).</returns>
        public static JsonSchemaBuilder FromType(this JsonSchemaBuilder builder, Type type, SchemaGeneratorConfiguration?configuration = null)
        {
            configuration ??= new SchemaGeneratorConfiguration();

            SchemaGenerationContextCache.Clear();
            var context = SchemaGenerationContextCache.Get(type, new List <Attribute>(), configuration);

            context.Optimize();

            context.Apply(builder);

            return(builder);
        }