<commit_before>package apiconsole

import (
	"encoding/json"
	"github.com/pkg/errors"
	"gopkg.in/yaml.v2"
	"reflect"
	"strings"
	"time"
	"unicode"
)

type Property struct {
	Name        string `yaml:"-"`
	Type        string `yaml:"type"`
	Description string `yaml:"description"`
}

func MergeWithTypes(ramlTemplate string, values ...interface{}) string {
	types := buildTypes(values...)

	raml := make(map[string]interface{})
	if err := yaml.Unmarshal([]byte(strings.Replace(ramlTemplate, "\t", " ", -1)), &raml); err != nil {
		panic(errors.Wrap(err, "Could not parse raml template"))
	}

	ramlTypes := raml["types"].(map[interface{}]interface{})
	for name, props := range types {
		if ramlTypes[name] == nil {
			ramlTypes[name] = props
		}
	}

	bytes, err := yaml.Marshal(raml)
	if err != nil {
		panic(errors.Wrap(err, "Could not marshal raml file to bytes"))
	}

	return "#%RAML 1.0\n" + string(bytes)
}

func buildTypes(values ...interface{}) map[string]interface{} {
	types := map[string][]Property{}

	for _, value := range values {
		structTypeName(types, reflect.TypeOf(value))
	}

	ramlTypes := make(map[string]interface{})
	for name, props := range types {
		ramlTypes[name] = typeToYaml(props)
	}
<commit_msg>Update reflection-magic.go<commit_after>package apiconsole

import (
	"encoding/json"
	"github.com/pkg/errors"
	"gopkg.in/yaml.v2"
	"reflect"
	"strings"
	"time"
	"unicode"
)

type Property struct {
	Name        string `yaml:"-"`
	Type        string `yaml:"type"`
	Description string `yaml:"description"`
}

func MergeWithTypes(ramlTemplate string, values ...interface{}) string {
	types := buildTypes(values...)

	raml := make(map[string]interface{})
	if err := yaml.Unmarshal([]byte(strings.Replace(ramlTemplate, "\t", " ", -1)), &raml); err != nil {
		panic(errors.Wrap(err, "Could not parse raml template"))
	}

	
	if raml["types"] != nil {
		ramlTypes := raml["types"].(map[interface{}]interface{})
		for name, props := range types {
			if ramlTypes[name] == nil {
				ramlTypes[name] = props
			}
		}
	}

	bytes, err := yaml.Marshal(raml)
	if err != nil {
		panic(errors.Wrap(err, "Could not marshal raml file to bytes"))
	}

	return "#%RAML 1.0\n" + string(bytes)
}

func buildTypes(values ...interface{}) map[string]interface{} {
	types := map[string][]Property{}

	for _, value := range values {
		structTypeName(types, reflect.TypeOf(value))
	}

	ramlTypes := make(map[string]interface{})
	for name, props := range types {
		ramlTypes[name] = typeToYaml(props)
	}

{'fraction_non_alphanumeric': 0.17234468937875752, 'fraction_numerical': 0.0032064128256513026, 'mean_word_length': 4.2217573221757325, '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': '903398', 'n_tokens_mistral': 917, 'n_tokens_neox': 868, 'n_words': 198}