@@ -63,13 +63,7 @@ func (c *ImageContent) MarshalJSON() ([]byte, error) {
63
63
if data == nil {
64
64
data = []byte {}
65
65
}
66
- wire := struct {
67
- Type string `json:"type"`
68
- MIMEType string `json:"mimeType"`
69
- Data []byte `json:"data"`
70
- Meta Meta `json:"_meta,omitempty"`
71
- Annotations * Annotations `json:"annotations,omitempty"`
72
- }{
66
+ wire := imageAudioWire {
73
67
Type : "image" ,
74
68
MIMEType : c .MIMEType ,
75
69
Data : data ,
@@ -100,13 +94,7 @@ func (c AudioContent) MarshalJSON() ([]byte, error) {
100
94
if data == nil {
101
95
data = []byte {}
102
96
}
103
- wire := struct {
104
- Type string `json:"type"`
105
- MIMEType string `json:"mimeType"`
106
- Data []byte `json:"data"`
107
- Meta Meta `json:"_meta,omitempty"`
108
- Annotations * Annotations `json:"annotations,omitempty"`
109
- }{
97
+ wire := imageAudioWire {
110
98
Type : "audio" ,
111
99
MIMEType : c .MIMEType ,
112
100
Data : data ,
@@ -123,6 +111,15 @@ func (c *AudioContent) fromWire(wire *wireContent) {
123
111
c .Annotations = wire .Annotations
124
112
}
125
113
114
+ // Custom wire format to ensure required fields are always included, even when empty.
115
+ type imageAudioWire struct {
116
+ Type string `json:"type"`
117
+ MIMEType string `json:"mimeType"`
118
+ Data []byte `json:"data"`
119
+ Meta Meta `json:"_meta,omitempty"`
120
+ Annotations * Annotations `json:"annotations,omitempty"`
121
+ }
122
+
126
123
// ResourceLink is a link to a resource
127
124
type ResourceLink struct {
128
125
URI string
0 commit comments