func Marshal(in *yaml.Node) []byte {
	clearStyle(in)
	bytes, _ := yaml.Marshal(in)
	return bytes
}
Marshal creates a yaml version of a structure in our preferred style
package compiler
import (
	"fmt"
	"regexp"
	"sort"
	"strconv"
	"github.com/googleapis/gnostic/jsonschema"
	"gopkg.in/yaml.v3"
)
func UnpackMap(in *yaml.Node) (*yaml.Node, bool) {
	if in == nil {
		return nil, false
	}
	return in, true
}
func SortedKeysForMap(m *yaml.Node) []string {
	keys := make([]string, 0)
	if m.Kind == yaml.MappingNode {
		for i := 0; i < len(m.Content); i += 2 {
			keys = append(keys, m.Content[i].Value)
		}
	}
	sort.Strings(keys)
	return keys
}
func MapHasKey(m *yaml.Node, key string) bool {
	if m == nil {
		return false
	}
	if m.Kind == yaml.MappingNode {
		for i := 0; i < len(m.Content); i += 2 {
			itemKey := m.Content[i].Value
			if key == itemKey {
				return true
			}
		}
	}
	return false
}
func MapValueForKey(m *yaml.Node, key string) *yaml.Node {
	if m == nil {
		return nil
	}
	if m.Kind == yaml.MappingNode {
		for i := 0; i < len(m.Content); i += 2 {
			itemKey := m.Content[i].Value
			if key == itemKey {
				return m.Content[i+1]
			}
		}
	}
	return nil
}
func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string {
	stringArray := make([]string, 0)
	for _, item := range interfaceArray {
		v, ok := item.(string)
		if ok {
			stringArray = append(stringArray, v)
		}
	}
	return stringArray
}
func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool) {
	if node.Kind != yaml.SequenceNode {
		return nil, false
	}
	return node, true
}
func BoolForScalarNode(node *yaml.Node) (bool, bool) {
	if node == nil {
		return false, false
	}
	if node.Kind == yaml.DocumentNode {
		return BoolForScalarNode(node.Content[0])
	}
	if node.Kind != yaml.ScalarNode {
		return false, false
	}
	if node.Tag != "!!bool" {
		return false, false
	}
	v, err := strconv.ParseBool(node.Value)
	if err != nil {
		return false, false
	}
	return v, true
}
func IntForScalarNode(node *yaml.Node) (int64, bool) {
	if node == nil {
		return 0, false
	}
	if node.Kind == yaml.DocumentNode {
		return IntForScalarNode(node.Content[0])
	}
	if node.Kind != yaml.ScalarNode {
		return 0, false
	}
	if node.Tag != "!!int" {
		return 0, false
	}
	v, err := strconv.ParseInt(node.Value, 10, 64)
	if err != nil {
		return 0, false
	}
	return v, true
}
func FloatForScalarNode(node *yaml.Node) (float64, bool) {
	if node == nil {
		return 0.0, false
	}
	if node.Kind == yaml.DocumentNode {
		return FloatForScalarNode(node.Content[0])
	}
	if node.Kind != yaml.ScalarNode {
		return 0.0, false
	}
	if (node.Tag != "!!int") && (node.Tag != "!!float") {
		return 0.0, false
	}
	v, err := strconv.ParseFloat(node.Value, 64)
	if err != nil {
		return 0.0, false
	}
	return v, true
}
func StringForScalarNode(node *yaml.Node) (string, bool) {
	if node == nil {
		return "", false
	}
	if node.Kind == yaml.DocumentNode {
		return StringForScalarNode(node.Content[0])
	}
	switch node.Kind {
	case yaml.ScalarNode:
		switch node.Tag {
		case "!!int":
			return node.Value, true
		case "!!str":
			return node.Value, true
		case "!!timestamp":
			return node.Value, true
		case "!!null":
			return "", true
		default:
			return "", false
		}
	default:
		return "", false
	}
}
func StringArrayForSequenceNode(node *yaml.Node) []string {
	stringArray := make([]string, 0)
	for _, item := range node.Content {
		v, ok := StringForScalarNode(item)
		if ok {
			stringArray = append(stringArray, v)
		}
	}
	return stringArray
}
func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string {
	missingKeys := make([]string, 0)
	for _, k := range requiredKeys {
		if !MapHasKey(m, k) {
			missingKeys = append(missingKeys, k)
		}
	}
	return missingKeys
}
func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string {
	invalidKeys := make([]string, 0)
	if m == nil || m.Kind != yaml.MappingNode {
		return invalidKeys
	}
	for i := 0; i < len(m.Content); i += 2 {
		key := m.Content[i].Value
		found := false
		for _, allowedKey := range allowedKeys {
			if key == allowedKey {
				found = true
				break
			}
		}
		if !found {
			for _, allowedPattern := range allowedPatterns {
				if allowedPattern.MatchString(key) {
					found = true
					break
				}
			}
			if !found {
				invalidKeys = append(invalidKeys, key)
			}
		}
	}
	return invalidKeys
}
func NewNullNode() *yaml.Node {
	node := &yaml.Node{
		Kind: yaml.ScalarNode,
		Tag:  "!!null",
	}
	return node
}
func NewMappingNode() *yaml.Node {
	return &yaml.Node{
		Kind:    yaml.MappingNode,
		Content: make([]*yaml.Node, 0),
	}
}
func NewSequenceNode() *yaml.Node {
	node := &yaml.Node{
		Kind:    yaml.SequenceNode,
		Content: make([]*yaml.Node, 0),
	}
	return node
}
func NewScalarNodeForString(s string) *yaml.Node {
	return &yaml.Node{
		Kind:  yaml.ScalarNode,
		Tag:   "!!str",
		Value: s,
	}
}
func NewSequenceNodeForStringArray(strings []string) *yaml.Node {
	node := &yaml.Node{
		Kind:    yaml.SequenceNode,
		Content: make([]*yaml.Node, 0),
	}
	for _, s := range strings {
		node.Content = append(node.Content, NewScalarNodeForString(s))
	}
	return node
}
func NewScalarNodeForBool(b bool) *yaml.Node {
	return &yaml.Node{
		Kind:  yaml.ScalarNode,
		Tag:   "!!bool",
		Value: fmt.Sprintf("%t", b),
	}
}
func NewScalarNodeForFloat(f float64) *yaml.Node {
	return &yaml.Node{
		Kind:  yaml.ScalarNode,
		Tag:   "!!float",
		Value: fmt.Sprintf("%g", f),
	}
}
func NewScalarNodeForInt(i int64) *yaml.Node {
	return &yaml.Node{
		Kind:  yaml.ScalarNode,
		Tag:   "!!int",
		Value: fmt.Sprintf("%d", i),
	}
}
func PluralProperties(count int) string {
	if count == 1 {
		return "property"
	}
	return "properties"
}
func StringArrayContainsValue(array []string, value string) bool {
	for _, item := range array {
		if item == value {
			return true
		}
	}
	return false
}
func StringArrayContainsValues(array []string, values []string) bool {
	for _, value := range values {
		if !StringArrayContainsValue(array, value) {
			return false
		}
	}
	return true
}
func StringValue(item interface{}) (value string, ok bool) {
	value, ok = item.(string)
	if ok {
		return value, ok
	}
	intValue, ok := item.(int)
	if ok {
		return strconv.Itoa(intValue), true
	}
	return "", false
}
func Description(item interface{}) string {
	value, ok := item.(*yaml.Node)
	if ok {
		return jsonschema.Render(value)
	}
	return fmt.Sprintf("%+v", item)
}
func Display(node *yaml.Node) string {
	switch node.Kind {
	case yaml.ScalarNode:
		switch node.Tag {
		case "!!str":
			return fmt.Sprintf("%s (string)", node.Value)
		}
	}
	return fmt.Sprintf("%+v (%T)", node, node)
}