<commit_before>package ru.lanwen.raml.rarc.util;

import com.jayway.restassured.path.json.JsonPath;
import com.sun.codemodel.JCodeModel;
import org.jsonschema2pojo.*;
import org.jsonschema2pojo.rules.RuleFactory;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.apache.commons.lang3.StringUtils.capitalize;
import static ru.lanwen.raml.rarc.api.ApiResourceClass.sanitize;

/**
 * Created by stassiak
 */
public class JsonCodegen {
    private final ResponseCodegenConfig config;

    public JsonCodegen(ResponseCodegenConfig config) {
        this.config = config;
    }

    public String generate() throws IOException {
        JCodeModel codeModel = new JCodeModel();
        URL source = new URL("file://" + config.getInputPath());
        GenerationConfig generationConfig = new DefaultGenerationConfig() {
            @Override
            public boolean isGenerateBuilders() { // set config option by overriding metho
                return true;
            }

            @Override
            public SourceType getSourceType() {
                if(JsonPath.from(source).get("$schema") != null) {
                    return SourceType.JSONSCHEMA;
                }
                return SourceType.JSON;<commit_msg>fix: resolving file url on Windows<commit_after>package ru.lanwen.raml.rarc.util;

import com.jayway.restassured.path.json.JsonPath;
import com.sun.codemodel.JCodeModel;
import org.jsonschema2pojo.*;
import org.jsonschema2pojo.rules.RuleFactory;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.apache.commons.lang3.StringUtils.capitalize;
import static ru.lanwen.raml.rarc.api.ApiResourceClass.sanitize;

/**
 * Created by stassiak
 */
public class JsonCodegen {
    private final ResponseCodegenConfig config;

    public JsonCodegen(ResponseCodegenConfig config) {
        this.config = config;
    }

    public String generate() throws IOException {
        JCodeModel codeModel = new JCodeModel();
        URL source = new File(config.getInputPath()).toURI().toURL();
        GenerationConfig generationConfig = new DefaultGenerationConfig() {
            @Override
            public boolean isGenerateBuilders() { // set config option by overriding metho
                return true;
            }

            @Override
            public SourceType getSourceType() {
                if(JsonPath.from(source).get("$schema") != null) {
                    return SourceType.JSONSCHEMA;
                }
                return SourceType.JSON;
{'fraction_non_alphanumeric': 0.09419210722263589, 'fraction_numerical': 0.0022338049143708115, 'mean_word_length': 2.784507042253521, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1372620', 'n_tokens_mistral': 762, 'n_tokens_neox': 739, 'n_words': 165}