func (t *Theme) UnmarshalJSON(data []byte) error {
	doc := &themeAlias{}
	if err := json.Unmarshal(data, doc); err != nil {
		return errors.Wrap(err, "failed to unmarshal Theme")
	}
	*t = Theme(*doc)

	if t.Attachments == nil {
		return errors.New("invalid theme: no attachments")
	}
	if t.Files == nil {
		return errors.New("invalid theme: no file list")
	}

	if err := t.Attachments.AddView(t.Files); err != nil {
		return err
	}
	for _, m := range t.Models {
		if err := t.Attachments.AddView(m.Files); err != nil {
			return err
		}
		m.Theme = t
	}
	return t.Validate()
}
// UnmarshalJSON implements the json.Unmarshaler interface for the Theme type.
UnmarshalJSON implements the json.Unmarshaler interface for the Theme type.
// UnmarshalJSON implements the json . Unmarshaler interface for the Theme type .
func (t *Theme) UnmarshalJSON(data []byte) error {
	doc := &themeAlias{}
	if err := json.Unmarshal(data, doc); err != nil {
		return errors.Wrap(err, "failed to unmarshal Theme")
	}
	*t = Theme(*doc)
	if t.Attachments == nil {
		return errors.New("invalid theme: no attachments")
	}
	if t.Files == nil {
		return errors.New("invalid theme: no file list")
	}
	if err := t.Attachments.AddView(t.Files); err != nil {
		return err
	}
	for _, m := range t.Models {
		if err := t.Attachments.AddView(m.Files); err != nil {
			return err
		}
		m.Theme = t
	}
	return t.Validate()
}
func ( t * Theme ) UnmarshalJSON ( data [ ] byte ) error { doc := & themeAlias { } if err := json . Unmarshal ( data , doc ) ; err != nil { return errors . Wrap ( err , " " ) } * t = Theme ( * doc ) if t . Attachments == nil { return errors . New ( " " ) } if t . Files == nil { return errors . New ( " " ) } if err := t . Attachments . AddView ( t . Files ) ; err != nil { return err } for _ , m := range t . Models { if err := t . Attachments . AddView ( m . Files ) ; err != nil { return err } m . Theme = t } return t . Validate ( ) }
UnmarshalJSON implements the json.Unmarshaler interface for the Theme type.
UnmarshalJSON implements the json . Unmarshaler interface for the Theme type .