func (schema *Schema) ResolveRefs() {
	rootSchema := schema
	count := 1
	for count > 0 {
		count = 0
		schema.applyToSchemas(
			func(schema *Schema, context string) {
				if schema.Ref != nil {
					resolvedRef, err := rootSchema.resolveJSONPointer(*(schema.Ref))
					if err != nil {
						log.Printf("%+v", err)
					} else if resolvedRef.TypeIs("object") {
					} else if context == "OneOf" {
					} else if resolvedRef.OneOf != nil {
					} else if resolvedRef.AdditionalProperties != nil {
					} else {
						schema.Ref = nil
						schema.CopyProperties(resolvedRef)
						count++
					}
				}
			}, "")
	}
}
ResolveRefs resolves "$ref" elements in a Schema and its children.
But if a reference refers to an object type, is inside a oneOf, or contains a oneOf,
the reference is kept and we expect downstream tools to separately model these
referenced schemas.
package jsonschema
import (
	"fmt"
	"log"
	"strings"
)
func (schema *Schema) IsEmpty() bool {
	return (schema.Schema == nil) &&
		(schema.ID == nil) &&
		(schema.MultipleOf == nil) &&
		(schema.Maximum == nil) &&
		(schema.ExclusiveMaximum == nil) &&
		(schema.Minimum == nil) &&
		(schema.ExclusiveMinimum == nil) &&
		(schema.MaxLength == nil) &&
		(schema.MinLength == nil) &&
		(schema.Pattern == nil) &&
		(schema.AdditionalItems == nil) &&
		(schema.Items == nil) &&
		(schema.MaxItems == nil) &&
		(schema.MinItems == nil) &&
		(schema.UniqueItems == nil) &&
		(schema.MaxProperties == nil) &&
		(schema.MinProperties == nil) &&
		(schema.Required == nil) &&
		(schema.AdditionalProperties == nil) &&
		(schema.Properties == nil) &&
		(schema.PatternProperties == nil) &&
		(schema.Dependencies == nil) &&
		(schema.Enumeration == nil) &&
		(schema.Type == nil) &&
		(schema.AllOf == nil) &&
		(schema.AnyOf == nil) &&
		(schema.OneOf == nil) &&
		(schema.Not == nil) &&
		(schema.Definitions == nil) &&
		(schema.Title == nil) &&
		(schema.Description == nil) &&
		(schema.Default == nil) &&
		(schema.Format == nil) &&
		(schema.Ref == nil)
}
func (schema *Schema) IsEqual(schema2 *Schema) bool {
	return schema.String() == schema2.String()
}
type SchemaOperation func(schema *Schema, context string)
func (schema *Schema) applyToSchemas(operation SchemaOperation, context string) {
	if schema.AdditionalItems != nil {
		s := schema.AdditionalItems.Schema
		if s != nil {
			s.applyToSchemas(operation, "AdditionalItems")
		}
	}
	if schema.Items != nil {
		if schema.Items.SchemaArray != nil {
			for _, s := range *(schema.Items.SchemaArray) {
				s.applyToSchemas(operation, "Items.SchemaArray")
			}
		} else if schema.Items.Schema != nil {
			schema.Items.Schema.applyToSchemas(operation, "Items.Schema")
		}
	}
	if schema.AdditionalProperties != nil {
		s := schema.AdditionalProperties.Schema
		if s != nil {
			s.applyToSchemas(operation, "AdditionalProperties")
		}
	}
	if schema.Properties != nil {
		for _, pair := range *(schema.Properties) {
			s := pair.Value
			s.applyToSchemas(operation, "Properties")
		}
	}
	if schema.PatternProperties != nil {
		for _, pair := range *(schema.PatternProperties) {
			s := pair.Value
			s.applyToSchemas(operation, "PatternProperties")
		}
	}
	if schema.Dependencies != nil {
		for _, pair := range *(schema.Dependencies) {
			schemaOrStringArray := pair.Value
			s := schemaOrStringArray.Schema
			if s != nil {
				s.applyToSchemas(operation, "Dependencies")
			}
		}
	}
	if schema.AllOf != nil {
		for _, s := range *(schema.AllOf) {
			s.applyToSchemas(operation, "AllOf")
		}
	}
	if schema.AnyOf != nil {
		for _, s := range *(schema.AnyOf) {
			s.applyToSchemas(operation, "AnyOf")
		}
	}
	if schema.OneOf != nil {
		for _, s := range *(schema.OneOf) {
			s.applyToSchemas(operation, "OneOf")
		}
	}
	if schema.Not != nil {
		schema.Not.applyToSchemas(operation, "Not")
	}
	if schema.Definitions != nil {
		for _, pair := range *(schema.Definitions) {
			s := pair.Value
			s.applyToSchemas(operation, "Definitions")
		}
	}
	operation(schema, context)
}
func (schema *Schema) CopyProperties(source *Schema) {
	if source.Schema != nil {
		schema.Schema = source.Schema
	}
	if source.ID != nil {
		schema.ID = source.ID
	}
	if source.MultipleOf != nil {
		schema.MultipleOf = source.MultipleOf
	}
	if source.Maximum != nil {
		schema.Maximum = source.Maximum
	}
	if source.ExclusiveMaximum != nil {
		schema.ExclusiveMaximum = source.ExclusiveMaximum
	}
	if source.Minimum != nil {
		schema.Minimum = source.Minimum
	}
	if source.ExclusiveMinimum != nil {
		schema.ExclusiveMinimum = source.ExclusiveMinimum
	}
	if source.MaxLength != nil {
		schema.MaxLength = source.MaxLength
	}
	if source.MinLength != nil {
		schema.MinLength = source.MinLength
	}
	if source.Pattern != nil {
		schema.Pattern = source.Pattern
	}
	if source.AdditionalItems != nil {
		schema.AdditionalItems = source.AdditionalItems
	}
	if source.Items != nil {
		schema.Items = source.Items
	}
	if source.MaxItems != nil {
		schema.MaxItems = source.MaxItems
	}
	if source.MinItems != nil {
		schema.MinItems = source.MinItems
	}
	if source.UniqueItems != nil {
		schema.UniqueItems = source.UniqueItems
	}
	if source.MaxProperties != nil {
		schema.MaxProperties = source.MaxProperties
	}
	if source.MinProperties != nil {
		schema.MinProperties = source.MinProperties
	}
	if source.Required != nil {
		schema.Required = source.Required
	}
	if source.AdditionalProperties != nil {
		schema.AdditionalProperties = source.AdditionalProperties
	}
	if source.Properties != nil {
		schema.Properties = source.Properties
	}
	if source.PatternProperties != nil {
		schema.PatternProperties = source.PatternProperties
	}
	if source.Dependencies != nil {
		schema.Dependencies = source.Dependencies
	}
	if source.Enumeration != nil {
		schema.Enumeration = source.Enumeration
	}
	if source.Type != nil {
		schema.Type = source.Type
	}
	if source.AllOf != nil {
		schema.AllOf = source.AllOf
	}
	if source.AnyOf != nil {
		schema.AnyOf = source.AnyOf
	}
	if source.OneOf != nil {
		schema.OneOf = source.OneOf
	}
	if source.Not != nil {
		schema.Not = source.Not
	}
	if source.Definitions != nil {
		schema.Definitions = source.Definitions
	}
	if source.Title != nil {
		schema.Title = source.Title
	}
	if source.Description != nil {
		schema.Description = source.Description
	}
	if source.Default != nil {
		schema.Default = source.Default
	}
	if source.Format != nil {
		schema.Format = source.Format
	}
	if source.Ref != nil {
		schema.Ref = source.Ref
	}
}
func (schema *Schema) TypeIs(typeName string) bool {
	if schema.Type != nil {
		if schema.Type.String != nil {
			return (*(schema.Type.String) == typeName)
		} else if schema.Type.StringArray != nil {
			for _, n := range *(schema.Type.StringArray) {
				if n == typeName {
					return true
				}
			}
		}
	}
	return false
}