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

package test

import "encoding/json"
import "fmt"
import "github.com/go-viper/mapstructure/v2"
import yaml "gopkg.in/yaml.v3"
import "reflect"
import "strings"

type ComposedWithMultipleRequired struct {
	// BaseField corresponds to the JSON schema field "baseField".
	BaseField string `json:"baseField" yaml:"baseField" mapstructure:"baseField"`

	// DirectField corresponds to the JSON schema field "directField".
	DirectField bool `json:"directField" yaml:"directField" mapstructure:"directField"`

	// MiddleField corresponds to the JSON schema field "middleField".
	MiddleField float64 `json:"middleField" yaml:"middleField" mapstructure:"middleField"`

	AdditionalProperties interface{} `mapstructure:",remain"`
}

// UnmarshalJSON implements json.Unmarshaler.
func (j *ComposedWithMultipleRequired) UnmarshalJSON(value []byte) error {
	var raw map[string]interface{}
	if err := json.Unmarshal(value, &raw); err != nil {
		return err
	}
	if _, ok := raw["baseField"]; raw != nil && !ok {
		return fmt.Errorf("field baseField in ComposedWithMultipleRequired: required")
	}
	if _, ok := raw["directField"]; raw != nil && !ok {
		return fmt.Errorf("field directField in ComposedWithMultipleRequired: required")
	}
	if _, ok := raw["middleField"]; raw != nil && !ok {
		return fmt.Errorf("field middleField in ComposedWithMultipleRequired: required")
	}
	type Plain ComposedWithMultipleRequired
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	st := reflect.TypeOf(Plain{})
	for i := range st.NumField() {
		delete(raw, st.Field(i).Name)
		delete(raw, strings.Split(st.Field(i).Tag.Get("json"), ",")[0])
	}
	if err := mapstructure.Decode(raw, &plain.AdditionalProperties); err != nil {
		return err
	}
	*j = ComposedWithMultipleRequired(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *ComposedWithMultipleRequired) UnmarshalYAML(value *yaml.Node) error {
	var raw map[string]interface{}
	if err := value.Decode(&raw); err != nil {
		return err
	}
	if _, ok := raw["baseField"]; raw != nil && !ok {
		return fmt.Errorf("field baseField in ComposedWithMultipleRequired: required")
	}
	if _, ok := raw["directField"]; raw != nil && !ok {
		return fmt.Errorf("field directField in ComposedWithMultipleRequired: required")
	}
	if _, ok := raw["middleField"]; raw != nil && !ok {
		return fmt.Errorf("field middleField in ComposedWithMultipleRequired: required")
	}
	type Plain ComposedWithMultipleRequired
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	st := reflect.TypeOf(Plain{})
	for i := range st.NumField() {
		delete(raw, st.Field(i).Name)
		delete(raw, strings.Split(st.Field(i).Tag.Get("json"), ",")[0])
	}
	if err := mapstructure.Decode(raw, &plain.AdditionalProperties); err != nil {
		return err
	}
	*j = ComposedWithMultipleRequired(plain)
	return nil
}

type MultipleRequiredBase struct {
	// BaseField corresponds to the JSON schema field "baseField".
	BaseField string `json:"baseField" yaml:"baseField" mapstructure:"baseField"`
}

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

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

type MultipleRequiredMiddle struct {
	// MiddleField corresponds to the JSON schema field "middleField".
	MiddleField float64 `json:"middleField" yaml:"middleField" mapstructure:"middleField"`
}

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

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