Skip to content

Commit e55e614

Browse files
fix(client): properly marshal embedded structs
1 parent 2dc3cae commit e55e614

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

shared/shared.go

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ type GetImageAttributesOptionsParam struct {
233233
}
234234

235235
func (r GetImageAttributesOptionsParam) MarshalJSON() (data []byte, err error) {
236-
type shadow GetImageAttributesOptionsParam
237-
return param.MarshalObject(r, (*shadow)(&r))
236+
type shadow struct {
237+
*GetImageAttributesOptionsParam
238+
MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field
239+
}
240+
return param.MarshalObject(r, shadow{&r, false})
238241
}
239242

240243
type ImageOverlayParam struct {
@@ -257,8 +260,11 @@ type ImageOverlayParam struct {
257260
}
258261

259262
func (r ImageOverlayParam) MarshalJSON() (data []byte, err error) {
260-
type shadow ImageOverlayParam
261-
return param.MarshalObject(r, (*shadow)(&r))
263+
type shadow struct {
264+
*ImageOverlayParam
265+
MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field
266+
}
267+
return param.MarshalObject(r, shadow{&r, false})
262268
}
263269

264270
func OverlayParamOfText(text string) OverlayUnionParam {
@@ -707,8 +713,11 @@ type SolidColorOverlayParam struct {
707713
}
708714

709715
func (r SolidColorOverlayParam) MarshalJSON() (data []byte, err error) {
710-
type shadow SolidColorOverlayParam
711-
return param.MarshalObject(r, (*shadow)(&r))
716+
type shadow struct {
717+
*SolidColorOverlayParam
718+
MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field
719+
}
720+
return param.MarshalObject(r, shadow{&r, false})
712721
}
713722

714723
type SolidColorOverlayTransformationParam struct {
@@ -941,8 +950,11 @@ type SubtitleOverlayParam struct {
941950
}
942951

943952
func (r SubtitleOverlayParam) MarshalJSON() (data []byte, err error) {
944-
type shadow SubtitleOverlayParam
945-
return param.MarshalObject(r, (*shadow)(&r))
953+
type shadow struct {
954+
*SubtitleOverlayParam
955+
MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field
956+
}
957+
return param.MarshalObject(r, shadow{&r, false})
946958
}
947959

948960
// Subtitle styling options.
@@ -1031,8 +1043,11 @@ type TextOverlayParam struct {
10311043
}
10321044

10331045
func (r TextOverlayParam) MarshalJSON() (data []byte, err error) {
1034-
type shadow TextOverlayParam
1035-
return param.MarshalObject(r, (*shadow)(&r))
1046+
type shadow struct {
1047+
*TextOverlayParam
1048+
MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field
1049+
}
1050+
return param.MarshalObject(r, shadow{&r, false})
10361051
}
10371052

10381053
type TextOverlayTransformationParam struct {
@@ -2201,6 +2216,9 @@ type VideoOverlayParam struct {
22012216
}
22022217

22032218
func (r VideoOverlayParam) MarshalJSON() (data []byte, err error) {
2204-
type shadow VideoOverlayParam
2205-
return param.MarshalObject(r, (*shadow)(&r))
2219+
type shadow struct {
2220+
*VideoOverlayParam
2221+
MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field
2222+
}
2223+
return param.MarshalObject(r, shadow{&r, false})
22062224
}

0 commit comments

Comments
 (0)