You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Validation error: [31:25] schema field properties.name.type value must be one of 'array', 'boolean', 'integer', 'null', 'number', 'object', 'string'
// Additional validation error: [31:25] schema field properties.name.type value must be one of 'array', 'boolean', 'integer', 'null', 'number', 'object', 'string'
// Validation error: [47:7] components.schemas failed to validate either Schema or bool: [50:15] schema.properties failed to validate either Schema or bool: [50:15] schema.properties expected object, got scalar
// At least one had a real unmarshalling error - return as unmarshalling failure
74
+
// At least one had a real unmarshaling error - return as unmarshaling failure
61
75
errs:= []error{}
62
76
ifleftUnmarshalErr!=nil {
63
77
errs=append(errs, leftUnmarshalErr)
@@ -71,19 +85,27 @@ func (v *EitherValue[L, R]) Unmarshal(ctx context.Context, parentName string, no
71
85
errs=append(errs, fmt.Errorf("right type validation failed: %v", rightValidationErrs))
72
86
}
73
87
74
-
returnnil, fmt.Errorf("unable to marshal into either %s or %s: %w", reflect.TypeOf((*L)(nil)).Elem().Name(), reflect.TypeOf((*R)(nil)).Elem().Name(), errors.Join(errs...))
88
+
returnnil, fmt.Errorf("unable to marshal into either %s or %s: %w", leftType, rightType, errors.Join(errs...))
75
89
}
76
90
77
91
// hasTypeMismatchErrors checks if the validation errors contain type mismatch errors
78
-
// indicating that the type couldn't be unmarshalled successfully
92
+
// indicating that the type couldn't be unmarshaled successfully.
93
+
// It ignores type mismatch errors from nested either values to avoid cascading failures.
0 commit comments