<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using FilterLists.Data.Models.Implementations;
using Newtonsoft.Json.Schema.Generation;

namespace FilterLists.Data.Schema
{
    public static class JsonSchemaGenerator
    {
        public static void WriteSchemaToFiles()
        {
            foreach (var type in GetTypesInNamespace(Assembly.GetExecutingAssembly(),
                "FilterLists.Data.Models.Implementations"))
            {
                if (type != typeof(List)) continue; //TEMP: only document List schema for now
                WriteSchemaToFile(type);
            }
        }

        private static void WriteSchemaToFile(Type type)
        {
            File.WriteAllText(
                Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) +
                type.Name + "Schema.json", new JSchemaGenerator().Generate(type).ToString());
        }

        private static IEnumerable<Type> GetTypesInNamespace(Assembly assembly, string @namespace)
        {
            return assembly.GetTypes().Where(t => string.Equals(t.Namespace, @namespace, StringComparison.Ordinal));
        }
    }
}<commit_msg>remove unneeded reflection schema stuff (for now)<commit_after>﻿using System;
using System.IO;
using FilterLists.Data.Models.Implementations;
using Newtonsoft.Json.Schema.Generation;

namespace FilterLists.Data.Schema
{
    public static class JsonSchemaGenerator
    {
        public static void WriteSchemaToFiles()
        {
            WriteSchemaToFile(typeof(List));
        }

        private static void WriteSchemaToFile(Type type)
        {
            File.WriteAllText(
                Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) + type.Name +
                "Schema.json", new JSchemaGenerator().Generate(type).ToString());
        }
    }
}
{'fraction_non_alphanumeric': 0.11682964487905301, 'fraction_numerical': 0.0, 'mean_word_length': 2.4714285714285715, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5445156', 'n_tokens_mistral': 523, 'n_tokens_neox': 491, 'n_words': 103}