// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.

package test

import "encoding/json"
import "errors"
import "fmt"
import yaml "gopkg.in/yaml.v3"

// object with anyOf properties as root
type AnyOf3 struct {
	// Bar corresponds to the JSON schema field "bar".
	Bar *float64 `json:"bar,omitempty,omitzero" yaml:"bar,omitempty" mapstructure:"bar,omitempty"`

	// Configurations corresponds to the JSON schema field "configurations".
	Configurations []interface{} `json:"configurations,omitempty,omitzero" yaml:"configurations,omitempty" mapstructure:"configurations,omitempty"`

	// Foo corresponds to the JSON schema field "foo".
	Foo *string `json:"foo,omitempty,omitzero" yaml:"foo,omitempty" mapstructure:"foo,omitempty"`
}

type AnyOf3_0 struct {
	// Foo corresponds to the JSON schema field "foo".
	Foo string `json:"foo" yaml:"foo" mapstructure:"foo"`
}

// UnmarshalJSON implements json.Unmarshaler.
func (j *AnyOf3_0) UnmarshalJSON(value []byte) error {
	var raw map[string]interface{}
	if err := json.Unmarshal(value, &raw); err != nil {
		return err
	}
	if _, ok := raw["foo"]; raw != nil && !ok {
		return fmt.Errorf("field foo in AnyOf3_0: required")
	}
	type Plain AnyOf3_0
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	*j = AnyOf3_0(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *AnyOf3_0) UnmarshalYAML(value *yaml.Node) error {
	var raw map[string]interface{}
	if err := value.Decode(&raw); err != nil {
		return err
	}
	if _, ok := raw["foo"]; raw != nil && !ok {
		return fmt.Errorf("field foo in AnyOf3_0: required")
	}
	type Plain AnyOf3_0
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	*j = AnyOf3_0(plain)
	return nil
}

type AnyOf3_1 struct {
	// Bar corresponds to the JSON schema field "bar".
	Bar float64 `json:"bar" yaml:"bar" mapstructure:"bar"`
}

// UnmarshalJSON implements json.Unmarshaler.
func (j *AnyOf3_1) UnmarshalJSON(value []byte) error {
	var raw map[string]interface{}
	if err := json.Unmarshal(value, &raw); err != nil {
		return err
	}
	if _, ok := raw["bar"]; raw != nil && !ok {
		return fmt.Errorf("field bar in AnyOf3_1: required")
	}
	type Plain AnyOf3_1
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	*j = AnyOf3_1(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *AnyOf3_1) UnmarshalYAML(value *yaml.Node) error {
	var raw map[string]interface{}
	if err := value.Decode(&raw); err != nil {
		return err
	}
	if _, ok := raw["bar"]; raw != nil && !ok {
		return fmt.Errorf("field bar in AnyOf3_1: required")
	}
	type Plain AnyOf3_1
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	*j = AnyOf3_1(plain)
	return nil
}

type AnyOf3_2 struct {
	// Configurations corresponds to the JSON schema field "configurations".
	Configurations []interface{} `json:"configurations,omitempty,omitzero" yaml:"configurations,omitempty" mapstructure:"configurations,omitempty"`
}

// UnmarshalJSON implements json.Unmarshaler.
func (j *AnyOf3_2) UnmarshalJSON(value []byte) error {
	type Plain AnyOf3_2
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	*j = AnyOf3_2(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *AnyOf3_2) UnmarshalYAML(value *yaml.Node) error {
	type Plain AnyOf3_2
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	*j = AnyOf3_2(plain)
	return nil
}

// UnmarshalJSON implements json.Unmarshaler.
func (j *AnyOf3) UnmarshalJSON(value []byte) error {
	var raw map[string]interface{}
	if err := json.Unmarshal(value, &raw); err != nil {
		return err
	}
	var anyOf3_0 AnyOf3_0
	var anyOf3_1 AnyOf3_1
	var anyOf3_2 AnyOf3_2
	var errs []error
	if err := anyOf3_0.UnmarshalJSON(value); err != nil {
		errs = append(errs, err)
	}
	if err := anyOf3_1.UnmarshalJSON(value); err != nil {
		errs = append(errs, err)
	}
	if err := anyOf3_2.UnmarshalJSON(value); err != nil {
		errs = append(errs, err)
	}
	if len(errs) == 3 {
		return fmt.Errorf("all validators failed: %s", errors.Join(errs...))
	}
	type Plain AnyOf3
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	*j = AnyOf3(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *AnyOf3) UnmarshalYAML(value *yaml.Node) error {
	var raw map[string]interface{}
	if err := value.Decode(&raw); err != nil {
		return err
	}
	var anyOf3_0 AnyOf3_0
	var anyOf3_1 AnyOf3_1
	var anyOf3_2 AnyOf3_2
	var errs []error
	if err := anyOf3_0.UnmarshalYAML(value); err != nil {
		errs = append(errs, err)
	}
	if err := anyOf3_1.UnmarshalYAML(value); err != nil {
		errs = append(errs, err)
	}
	if err := anyOf3_2.UnmarshalYAML(value); err != nil {
		errs = append(errs, err)
	}
	if len(errs) == 3 {
		return fmt.Errorf("all validators failed: %s", errors.Join(errs...))
	}
	type Plain AnyOf3
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	*j = AnyOf3(plain)
	return nil
}
