fix recursive struct validation during JSON marshaling (#5883)

This commit is contained in:
Dogan Can Bakir
2024-12-19 18:06:21 +03:00
committed by GitHub
parent f21a82aac3
commit 358249bdb4

View File

@@ -521,7 +521,8 @@ func (template *Template) hasMultipleRequests() bool {
// MarshalJSON forces recursive struct validation during marshal operation
func (template *Template) MarshalJSON() ([]byte, error) {
out, marshalErr := json.Marshal(template)
type TemplateAlias Template //avoid recursion
out, marshalErr := json.Marshal((*TemplateAlias)(template))
errValidate := validate.New().Struct(template)
return out, multierr.Append(marshalErr, errValidate)
}