File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,23 @@ type ToolInputSchema struct {
113113 Required []string `json:"required,omitempty"`
114114}
115115
116+ // MarshalJSON implements the json.Marshaler interface for ToolInputSchema.
117+ func (tis ToolInputSchema ) MarshalJSON () ([]byte , error ) {
118+ m := make (map [string ]interface {})
119+ m ["type" ] = tis .Type
120+
121+ // Marshal Properties to '{}' rather than `nil` when its length equals zero
122+ if tis .Properties != nil {
123+ m ["properties" ] = tis .Properties
124+ }
125+
126+ if len (tis .Required ) > 0 {
127+ m ["required" ] = tis .Required
128+ }
129+
130+ return json .Marshal (m )
131+ }
132+
116133type ToolAnnotation struct {
117134 // Human-readable title for the tool
118135 Title string `json:"title,omitempty"`
You can’t perform that action at this time.
0 commit comments