diff --git a/cmd/abuseReport/insert.go b/cmd/abuseReport/insert.go index a61c707..6606a03 100644 --- a/cmd/abuseReport/insert.go +++ b/cmd/abuseReport/insert.go @@ -4,7 +4,7 @@ package abuseReport import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -43,11 +43,11 @@ var insertInSchema = &jsonschema.Schema{ "related_entity_id": {Type: "string", Description: relatedEntityUsage}, "parts": { Type: "array", Description: "Parts to include in the response", - Items: &jsonschema.Schema{Type: "string"}, Default: json.RawMessage(`["snippet"]`), + Items: &jsonschema.Schema{Type: "string"}, Default: jsontext.Value(`["snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/activity/list.go b/cmd/activity/list.go index 3c1985c..da6f76c 100644 --- a/cmd/activity/list.go +++ b/cmd/activity/list.go @@ -4,7 +4,7 @@ package activity import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -40,7 +40,7 @@ var listInSchema = &jsonschema.Schema{ }, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), Minimum: new(float64(0)), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "published_after": {Type: "string", Description: paUsage}, "published_before": {Type: "string", Description: pbUsage}, @@ -48,11 +48,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","contentDetails"]`), + Default: jsontext.Value(`["id","snippet","contentDetails"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/caption/insert.go b/cmd/caption/insert.go index cba0556..bdb741e 100644 --- a/cmd/caption/insert.go +++ b/cmd/caption/insert.go @@ -4,7 +4,7 @@ package caption import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -38,7 +38,7 @@ var insertInSchema = &jsonschema.Schema{ "audio_track_type": { Type: "string", Description: attUsage, Enum: []any{"unknown", "primary", "commentary", "descriptive"}, - Default: json.RawMessage(`"unknown"`), + Default: jsontext.Value(`"unknown"`), }, "is_auto_synced": {Type: "boolean", Description: iasUsage}, "is_cc": {Type: "boolean", Description: iscUsage}, @@ -50,7 +50,7 @@ var insertInSchema = &jsonschema.Schema{ "track_kind": { Type: "string", Description: tkUsage, Enum: []any{"standard", "ASR", "forced"}, - Default: json.RawMessage(`"standard"`), + Default: jsontext.Value(`"standard"`), }, "video_id": {Type: "string", Description: vidUsage}, "on_behalf_of": {Type: "string", Description: pkg.OBOUsage}, @@ -58,7 +58,7 @@ var insertInSchema = &jsonschema.Schema{ "output": { Type: "string", Description: pkg.SilentUsage, Enum: []any{"json", "yaml", "silent"}, - Default: json.RawMessage(`"yaml"`), + Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/caption/list.go b/cmd/caption/list.go index a5d5c26..628e1b1 100644 --- a/cmd/caption/list.go +++ b/cmd/caption/list.go @@ -4,7 +4,7 @@ package caption import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -44,12 +44,12 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Description: pkg.TableUsage, Enum: []any{"json", "yaml", "table"}, - Default: json.RawMessage(`"yaml"`), + Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/caption/update.go b/cmd/caption/update.go index 0cbc9fb..267acf2 100644 --- a/cmd/caption/update.go +++ b/cmd/caption/update.go @@ -4,7 +4,7 @@ package caption import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -37,7 +37,7 @@ var updateInSchema = &jsonschema.Schema{ "file": {Type: "string", Description: fileUsage}, "audio_track_type": { Type: "string", Description: attUsage, - Default: json.RawMessage(`"unknown"`), + Default: jsontext.Value(`"unknown"`), }, "is_auto_synced": {Type: "boolean", Description: iasUsage}, "is_cc": {Type: "boolean", Description: iscUsage}, @@ -49,7 +49,7 @@ var updateInSchema = &jsonschema.Schema{ "track_kind": { Type: "string", Description: tkUsage, Enum: []any{"standard", "ASR", "forced"}, - Default: json.RawMessage(`"standard"`), + Default: jsontext.Value(`"standard"`), }, "video_id": {Type: "string", Description: vidUsage}, "on_behalf_of": {Type: "string", Description: pkg.OBOUsage}, @@ -57,7 +57,7 @@ var updateInSchema = &jsonschema.Schema{ "output": { Type: "string", Description: pkg.SilentUsage, Enum: []any{"json", "yaml", "silent"}, - Default: json.RawMessage(`"yaml"`), + Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/channel/list.go b/cmd/channel/list.go index 5dc78de..f38850b 100644 --- a/cmd/channel/list.go +++ b/cmd/channel/list.go @@ -4,7 +4,7 @@ package channel import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -43,7 +43,7 @@ var listInSchema = &jsonschema.Schema{ "ids": { Type: "array", Items: &jsonschema.Schema{Type: "string"}, Description: listIdsUsage, - Default: json.RawMessage(`[]`), + Default: jsontext.Value(`[]`), }, "for": { Type: "string", Description: forUsage, @@ -51,18 +51,18 @@ var listInSchema = &jsonschema.Schema{ }, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","status"]`), + Default: jsontext.Value(`["id","snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/channel/update.go b/cmd/channel/update.go index 5afb64f..abc7cbb 100644 --- a/cmd/channel/update.go +++ b/cmd/channel/update.go @@ -4,7 +4,7 @@ package channel import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -47,7 +47,7 @@ var updateInSchema = &jsonschema.Schema{ "title": {Type: "string", Description: titleUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/channelBanner/insert.go b/cmd/channelBanner/insert.go index d73f9ac..ce4706b 100644 --- a/cmd/channelBanner/insert.go +++ b/cmd/channelBanner/insert.go @@ -4,7 +4,7 @@ package channelBanner import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -45,7 +45,7 @@ var insertInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/channelSection/list.go b/cmd/channelSection/list.go index 5c26494..d80d9c9 100644 --- a/cmd/channelSection/list.go +++ b/cmd/channelSection/list.go @@ -4,7 +4,7 @@ package channelSection import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -45,11 +45,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/comment/insert.go b/cmd/comment/insert.go index d9775f0..8441059 100644 --- a/cmd/comment/insert.go +++ b/cmd/comment/insert.go @@ -4,7 +4,7 @@ package comment import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -43,7 +43,7 @@ var insertInSchema = &jsonschema.Schema{ "video_id": {Type: "string", Description: vidUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/comment/list.go b/cmd/comment/list.go index f69e9cb..3bec289 100644 --- a/cmd/comment/list.go +++ b/cmd/comment/list.go @@ -4,7 +4,7 @@ package comment import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -40,22 +40,22 @@ var listInSchema = &jsonschema.Schema{ }, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "parent_id": {Type: "string", Description: listPidUsage}, "text_format": { Type: "string", Enum: []any{"textFormatUnspecified", "html", "plainText"}, - Description: tfUsage, Default: json.RawMessage(`"html"`), + Description: tfUsage, Default: jsontext.Value(`"html"`), }, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/comment/markAsSpam.go b/cmd/comment/markAsSpam.go index 059fd15..3ef444e 100644 --- a/cmd/comment/markAsSpam.go +++ b/cmd/comment/markAsSpam.go @@ -4,7 +4,7 @@ package comment import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -39,7 +39,7 @@ var markAsSpamInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/comment/setModerationStatus.go b/cmd/comment/setModerationStatus.go index a7d7117..f95fd00 100644 --- a/cmd/comment/setModerationStatus.go +++ b/cmd/comment/setModerationStatus.go @@ -4,7 +4,7 @@ package comment import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -46,7 +46,7 @@ var setModerationStatusInSchema = &jsonschema.Schema{ "ban_author": {Type: "boolean", Description: baUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/comment/update.go b/cmd/comment/update.go index acacf3a..7888ff9 100644 --- a/cmd/comment/update.go +++ b/cmd/comment/update.go @@ -4,7 +4,7 @@ package comment import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -48,7 +48,7 @@ var updateInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/commentThread/insert.go b/cmd/commentThread/insert.go index a7d9878..39122ba 100644 --- a/cmd/commentThread/insert.go +++ b/cmd/commentThread/insert.go @@ -4,7 +4,7 @@ package commentThread import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -41,7 +41,7 @@ var insertInSchema = &jsonschema.Schema{ "video_id": {Type: "string", Description: insertVidUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/commentThread/list.go b/cmd/commentThread/list.go index 5659c0f..e7ea3f5 100644 --- a/cmd/commentThread/list.go +++ b/cmd/commentThread/list.go @@ -4,7 +4,7 @@ package commentThread import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -45,32 +45,32 @@ var listInSchema = &jsonschema.Schema{ "channel_id": {Type: "string", Description: cidUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "moderation_status": { Type: "string", Enum: []any{"published", "heldForReview", "likelySpam", "rejected"}, - Description: msUsage, Default: json.RawMessage(`"published"`), + Description: msUsage, Default: jsontext.Value(`"published"`), }, "order": { Type: "string", Enum: []any{"orderUnspecified", "time", "relevance"}, - Description: orderUsage, Default: json.RawMessage(`"time"`), + Description: orderUsage, Default: jsontext.Value(`"time"`), }, "search_terms": {Type: "string", Description: stUsage}, "text_format": { Type: "string", Enum: []any{"textFormatUnspecified", "html"}, - Description: tfUsage, Default: json.RawMessage(`"html"`), + Description: tfUsage, Default: jsontext.Value(`"html"`), }, "video_id": {Type: "string", Description: listVidUsage}, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/liveBroadcast/bind.go b/cmd/liveBroadcast/bind.go index aa65079..3d51b5c 100644 --- a/cmd/liveBroadcast/bind.go +++ b/cmd/liveBroadcast/bind.go @@ -4,7 +4,7 @@ package liveBroadcast import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -45,11 +45,11 @@ var bindInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","contentDetails","status"]`), + Default: jsontext.Value(`["id","snippet","contentDetails","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveBroadcast/insert.go b/cmd/liveBroadcast/insert.go index f0465b9..931945b 100644 --- a/cmd/liveBroadcast/insert.go +++ b/cmd/liveBroadcast/insert.go @@ -4,7 +4,7 @@ package liveBroadcast import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -47,11 +47,11 @@ var insertInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet","status","contentDetails"]`), + Default: jsontext.Value(`["snippet","status","contentDetails"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveBroadcast/insertCuepoint.go b/cmd/liveBroadcast/insertCuepoint.go index 57034b1..6fb65fa 100644 --- a/cmd/liveBroadcast/insertCuepoint.go +++ b/cmd/liveBroadcast/insertCuepoint.go @@ -4,7 +4,7 @@ package liveBroadcast import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -50,7 +50,7 @@ var insertCuepointInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveBroadcast/list.go b/cmd/liveBroadcast/list.go index c80b161..62da56e 100644 --- a/cmd/liveBroadcast/list.go +++ b/cmd/liveBroadcast/list.go @@ -4,7 +4,7 @@ package liveBroadcast import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -43,7 +43,7 @@ var listInSchema = &jsonschema.Schema{ "broadcast_type": {Type: "string", Enum: []any{"all", "event", "persistent"}, Description: btUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), Minimum: new(float64(0)), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "on_behalf_of_content_owner_channel": { @@ -52,11 +52,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","status"]`), + Default: jsontext.Value(`["id","snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/liveBroadcast/transition.go b/cmd/liveBroadcast/transition.go index 2e99a60..3276103 100644 --- a/cmd/liveBroadcast/transition.go +++ b/cmd/liveBroadcast/transition.go @@ -4,7 +4,7 @@ package liveBroadcast import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -49,11 +49,11 @@ var transitionInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","status"]`), + Default: jsontext.Value(`["id","snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveBroadcast/update.go b/cmd/liveBroadcast/update.go index 4699ba7..c191d38 100644 --- a/cmd/liveBroadcast/update.go +++ b/cmd/liveBroadcast/update.go @@ -4,7 +4,7 @@ package liveBroadcast import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -52,7 +52,7 @@ var updateInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveChatBan/insert.go b/cmd/liveChatBan/insert.go index 445cb39..6d8316c 100644 --- a/cmd/liveChatBan/insert.go +++ b/cmd/liveChatBan/insert.go @@ -4,7 +4,7 @@ package liveChatBan import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -38,11 +38,11 @@ var insertInSchema = &jsonschema.Schema{ "ban_duration_seconds": {Type: "number", Description: banDurationUsage}, "parts": { Type: "array", Description: "Parts to include in the response", - Items: &jsonschema.Schema{Type: "string"}, Default: json.RawMessage(`["snippet"]`), + Items: &jsonschema.Schema{Type: "string"}, Default: jsontext.Value(`["snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveChatMessage/insert.go b/cmd/liveChatMessage/insert.go index 35f20ee..3a4fa12 100644 --- a/cmd/liveChatMessage/insert.go +++ b/cmd/liveChatMessage/insert.go @@ -4,7 +4,7 @@ package liveChatMessage import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -34,11 +34,11 @@ var insertInSchema = &jsonschema.Schema{ "message_text": {Type: "string", Description: msgUsage}, "parts": { Type: "array", Description: "Parts to include in the response", - Items: &jsonschema.Schema{Type: "string"}, Default: json.RawMessage(`["snippet"]`), + Items: &jsonschema.Schema{Type: "string"}, Default: jsontext.Value(`["snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveChatMessage/list.go b/cmd/liveChatMessage/list.go index b8e1801..ea4a1fb 100644 --- a/cmd/liveChatMessage/list.go +++ b/cmd/liveChatMessage/list.go @@ -4,7 +4,7 @@ package liveChatMessage import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -35,17 +35,17 @@ var listInSchema = &jsonschema.Schema{ "hl": {Type: "string", Description: "Localization language for system messages"}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet","authorDetails"]`), + Default: jsontext.Value(`["snippet","authorDetails"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/liveChatMessage/transition.go b/cmd/liveChatMessage/transition.go index 2c9daf7..6ceb8c1 100644 --- a/cmd/liveChatMessage/transition.go +++ b/cmd/liveChatMessage/transition.go @@ -4,7 +4,7 @@ package liveChatMessage import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -41,7 +41,7 @@ var transitionInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveChatModerator/insert.go b/cmd/liveChatModerator/insert.go index ab9a9f0..bc5435f 100644 --- a/cmd/liveChatModerator/insert.go +++ b/cmd/liveChatModerator/insert.go @@ -4,7 +4,7 @@ package liveChatModerator import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -34,11 +34,11 @@ var insertInSchema = &jsonschema.Schema{ "moderator_channel_id": {Type: "string", Description: mcidUsage}, "parts": { Type: "array", Description: "Parts to include in the response", - Items: &jsonschema.Schema{Type: "string"}, Default: json.RawMessage(`["snippet"]`), + Items: &jsonschema.Schema{Type: "string"}, Default: jsontext.Value(`["snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveChatModerator/list.go b/cmd/liveChatModerator/list.go index 9491b84..0cc12ee 100644 --- a/cmd/liveChatModerator/list.go +++ b/cmd/liveChatModerator/list.go @@ -4,7 +4,7 @@ package liveChatModerator import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -34,17 +34,17 @@ var listInSchema = &jsonschema.Schema{ "live_chat_id": {Type: "string", Description: lcidUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet"]`), + Default: jsontext.Value(`["snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/liveStream/insert.go b/cmd/liveStream/insert.go index 724c9e3..0ca842d 100644 --- a/cmd/liveStream/insert.go +++ b/cmd/liveStream/insert.go @@ -4,7 +4,7 @@ package liveStream import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -53,11 +53,11 @@ var insertInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet","cdn","status"]`), + Default: jsontext.Value(`["snippet","cdn","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/liveStream/list.go b/cmd/liveStream/list.go index 9dad38e..6c9807a 100644 --- a/cmd/liveStream/list.go +++ b/cmd/liveStream/list.go @@ -4,7 +4,7 @@ package liveStream import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -41,7 +41,7 @@ var listInSchema = &jsonschema.Schema{ "mine": {Type: "boolean", Description: "List streams owned by the authenticated user"}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), Minimum: new(float64(0)), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "on_behalf_of_content_owner_channel": { @@ -50,11 +50,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","cdn","status"]`), + Default: jsontext.Value(`["id","snippet","cdn","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/liveStream/update.go b/cmd/liveStream/update.go index 20ef051..11a9365 100644 --- a/cmd/liveStream/update.go +++ b/cmd/liveStream/update.go @@ -4,7 +4,7 @@ package liveStream import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -58,7 +58,7 @@ var updateInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/member/list.go b/cmd/member/list.go index 3bf2bae..21e768e 100644 --- a/cmd/member/list.go +++ b/cmd/member/list.go @@ -4,7 +4,7 @@ package member import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -35,22 +35,22 @@ var listInSchema = &jsonschema.Schema{ "has_access_to_level": {Type: "string", Description: hatlUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "mode": { Type: "string", Description: mmUsage, Enum: []any{"listMembersModeUnknown", "updates", "all_current"}, - Default: json.RawMessage(`"all_current"`), + Default: jsontext.Value(`"all_current"`), }, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet"]`), + Default: jsontext.Value(`["snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/membershipsLevel/list.go b/cmd/membershipsLevel/list.go index 9bf34f3..21b3ca2 100644 --- a/cmd/membershipsLevel/list.go +++ b/cmd/membershipsLevel/list.go @@ -4,7 +4,7 @@ package membershipsLevel import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -32,11 +32,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id", "snippet"]`), + Default: jsontext.Value(`["id", "snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/playlist/insert.go b/cmd/playlist/insert.go index 235511b..13c25b2 100644 --- a/cmd/playlist/insert.go +++ b/cmd/playlist/insert.go @@ -4,7 +4,7 @@ package playlist import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -49,7 +49,7 @@ var insertInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/playlist/list.go b/cmd/playlist/list.go index e49bb94..47a584f 100644 --- a/cmd/playlist/list.go +++ b/cmd/playlist/list.go @@ -4,7 +4,7 @@ package playlist import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -43,7 +43,7 @@ var listInSchema = &jsonschema.Schema{ "hl": {Type: "string", Description: hlUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "mine": { @@ -60,11 +60,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","status"]`), + Default: jsontext.Value(`["id","snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/playlist/update.go b/cmd/playlist/update.go index cef028a..14142b9 100644 --- a/cmd/playlist/update.go +++ b/cmd/playlist/update.go @@ -4,7 +4,7 @@ package playlist import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -55,7 +55,7 @@ var updateInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/playlistImage/insert.go b/cmd/playlistImage/insert.go index d8cd161..adbb945 100644 --- a/cmd/playlistImage/insert.go +++ b/cmd/playlistImage/insert.go @@ -4,7 +4,7 @@ package playlistImage import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -55,7 +55,7 @@ var insertInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/playlistImage/list.go b/cmd/playlistImage/list.go index d8d8f49..0158b5f 100644 --- a/cmd/playlistImage/list.go +++ b/cmd/playlistImage/list.go @@ -4,7 +4,7 @@ package playlistImage import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -34,7 +34,7 @@ var listInSchema = &jsonschema.Schema{ "parent": {Type: "string", Description: parentUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "on_behalf_of_content_owner": { @@ -48,11 +48,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","kind","snippet"]`), + Default: jsontext.Value(`["id","kind","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/playlistImage/update.go b/cmd/playlistImage/update.go index 514d19a..26a6983 100644 --- a/cmd/playlistImage/update.go +++ b/cmd/playlistImage/update.go @@ -4,7 +4,7 @@ package playlistImage import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -50,7 +50,7 @@ var updateInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/playlistItem/insert.go b/cmd/playlistItem/insert.go index 45cd112..ab0478b 100644 --- a/cmd/playlistItem/insert.go +++ b/cmd/playlistItem/insert.go @@ -4,7 +4,7 @@ package playlistItem import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -51,7 +51,7 @@ var insertInSchema = &jsonschema.Schema{ "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/playlistItem/list.go b/cmd/playlistItem/list.go index 855b886..cee07e6 100644 --- a/cmd/playlistItem/list.go +++ b/cmd/playlistItem/list.go @@ -4,7 +4,7 @@ package playlistItem import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -42,7 +42,7 @@ var listInSchema = &jsonschema.Schema{ "playlist_id": {Type: "string", Description: listPidUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "video_id": {Type: "string", Description: vidUsage}, @@ -50,11 +50,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","status"]`), + Default: jsontext.Value(`["id","snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/playlistItem/update.go b/cmd/playlistItem/update.go index e81ab8c..3de6870 100644 --- a/cmd/playlistItem/update.go +++ b/cmd/playlistItem/update.go @@ -4,7 +4,7 @@ package playlistItem import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -49,7 +49,7 @@ var updateInSchema = &jsonschema.Schema{ "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/search/list.go b/cmd/search/list.go index 2dca69b..69f6b9c 100644 --- a/cmd/search/list.go +++ b/cmd/search/list.go @@ -4,7 +4,7 @@ package search import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -38,11 +38,11 @@ var listInSchema = &jsonschema.Schema{ "channel_id": {Type: "string", Description: cidUsage}, "channel_type": { Type: "string", Enum: []any{"channelTypeUnspecified", "any", "show"}, - Description: ctUsage, Default: json.RawMessage(`"channelTypeUnspecified"`), + Description: ctUsage, Default: jsontext.Value(`"channelTypeUnspecified"`), }, "event_type": { Type: "string", Enum: []any{"none", "upcoming", "live", "completed"}, - Description: etUsage, Default: json.RawMessage(`"none"`), + Description: etUsage, Default: jsontext.Value(`"none"`), }, "for": { Type: "string", Description: forUsage, @@ -52,13 +52,13 @@ var listInSchema = &jsonschema.Schema{ "location_radius": {Type: "string", Description: lrUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "order": { Type: "string", Description: orderUsage, - Default: json.RawMessage(`"relevance"`), + Default: jsontext.Value(`"relevance"`), }, "published_after": {Type: "string", Description: paUsage}, "published_before": {Type: "string", Description: pbUsage}, @@ -70,7 +70,7 @@ var listInSchema = &jsonschema.Schema{ Enum: []any{ "safeSearchSettingUnspecified", "none", "moderate", "strict", }, - Default: json.RawMessage(`"moderate"`), + Default: jsontext.Value(`"moderate"`), }, "topic_id": {Type: "string", Description: tidUsage}, "types": { @@ -82,20 +82,20 @@ var listInSchema = &jsonschema.Schema{ Enum: []any{ "videoCaptionUnspecified", "any", "closedCaption", "none", }, - Default: json.RawMessage(`"any"`), + Default: jsontext.Value(`"any"`), }, "video_category_id": {Type: "string", Description: vcidUsage}, "video_definition": {Type: "string", Description: vdeUsage}, "video_dimension": { Type: "string", Enum: []any{"any", "2d", "3d"}, - Description: vdiUsage, Default: json.RawMessage(`"any"`), + Description: vdiUsage, Default: jsontext.Value(`"any"`), }, "video_duration": { Type: "string", Description: vduUsage, Enum: []any{ "videoDurationUnspecified", "any", "short", "medium", "long", }, - Default: json.RawMessage(`"any"`), + Default: jsontext.Value(`"any"`), }, "video_embeddable": { Type: "string", Description: veUsage, @@ -122,11 +122,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/subscription/insert.go b/cmd/subscription/insert.go index 3b02d8b..f544be4 100644 --- a/cmd/subscription/insert.go +++ b/cmd/subscription/insert.go @@ -4,7 +4,7 @@ package subscription import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -39,7 +39,7 @@ var insertInSchema = &jsonschema.Schema{ "title": {Type: "string", Description: titleUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/subscription/list.go b/cmd/subscription/list.go index 068a848..2f1e850 100644 --- a/cmd/subscription/list.go +++ b/cmd/subscription/list.go @@ -4,7 +4,7 @@ package subscription import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -45,7 +45,7 @@ var listInSchema = &jsonschema.Schema{ "for_channel_id": {Type: "string", Description: fcidUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "for": { @@ -65,16 +65,16 @@ var listInSchema = &jsonschema.Schema{ Enum: []any{ "subscriptionOrderUnspecified", "relevance", "unread", "alphabetical", }, - Default: json.RawMessage(`"relevance"`), + Default: jsontext.Value(`"relevance"`), }, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/superChatEvent/list.go b/cmd/superChatEvent/list.go index f2bd7c5..7e672de 100644 --- a/cmd/superChatEvent/list.go +++ b/cmd/superChatEvent/list.go @@ -4,7 +4,7 @@ package superChatEvent import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -32,17 +32,17 @@ var listInSchema = &jsonschema.Schema{ "hl": {Type: "string", Description: hlUsage}, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/thirdPartyLink/insert.go b/cmd/thirdPartyLink/insert.go index a633bd1..1a1ef15 100644 --- a/cmd/thirdPartyLink/insert.go +++ b/cmd/thirdPartyLink/insert.go @@ -4,7 +4,7 @@ package thirdPartyLink import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -37,11 +37,11 @@ var insertInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet","status"]`), + Default: jsontext.Value(`["snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/thirdPartyLink/list.go b/cmd/thirdPartyLink/list.go index ad06dd1..262fc23 100644 --- a/cmd/thirdPartyLink/list.go +++ b/cmd/thirdPartyLink/list.go @@ -4,7 +4,7 @@ package thirdPartyLink import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -39,11 +39,11 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet","status"]`), + Default: jsontext.Value(`["snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/thirdPartyLink/update.go b/cmd/thirdPartyLink/update.go index ff0ff1f..87f7ae4 100644 --- a/cmd/thirdPartyLink/update.go +++ b/cmd/thirdPartyLink/update.go @@ -4,7 +4,7 @@ package thirdPartyLink import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -39,11 +39,11 @@ var updateInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["snippet","status"]`), + Default: jsontext.Value(`["snippet","status"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/thumbnail/set.go b/cmd/thumbnail/set.go index c671ef4..b64e63c 100644 --- a/cmd/thumbnail/set.go +++ b/cmd/thumbnail/set.go @@ -4,7 +4,7 @@ package thumbnail import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -36,7 +36,7 @@ var setInSchema = &jsonschema.Schema{ "video_id": {Type: "string", Description: vidUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, }, diff --git a/cmd/video/getRating.go b/cmd/video/getRating.go index 2b7949e..98ed859 100644 --- a/cmd/video/getRating.go +++ b/cmd/video/getRating.go @@ -4,7 +4,7 @@ package video import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -39,7 +39,7 @@ var getRatingInSchema = &jsonschema.Schema{ "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/video/insert.go b/cmd/video/insert.go index a58a140..b3f9875 100644 --- a/cmd/video/insert.go +++ b/cmd/video/insert.go @@ -4,7 +4,7 @@ package video import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" @@ -46,7 +46,7 @@ var insertInSchema = &jsonschema.Schema{ "language": {Type: "string", Description: insertLangUsage}, "license": { Type: "string", Enum: []any{"youtube", "creativeCommon"}, - Description: licenseUsage, Default: json.RawMessage(`"youtube"`), + Description: licenseUsage, Default: jsontext.Value(`"youtube"`), }, "thumbnail": {Type: "string", Description: thumbnailUsage}, "channel_id": {Type: "string", Description: chidUsage}, @@ -76,7 +76,7 @@ var insertInSchema = &jsonschema.Schema{ }, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/video/list.go b/cmd/video/list.go index a861f13..6e08093 100644 --- a/cmd/video/list.go +++ b/cmd/video/list.go @@ -4,7 +4,7 @@ package video import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -57,18 +57,18 @@ var listInSchema = &jsonschema.Schema{ }, "max_results": { Type: "number", Description: pkg.MRUsage, - Default: json.RawMessage("5"), Minimum: new(float64(0)), + Default: jsontext.Value("5"), Minimum: new(float64(0)), }, "on_behalf_of_content_owner": {Type: "string", Description: pkg.OBOCOUsage}, "rating": {Type: "string", Description: listMrUsage}, "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet","status","statistics"]`), + Default: jsontext.Value(`["id","snippet","status","statistics"]`), }, "output": { Type: "string", Enum: []any{"json", "yaml", "table"}, - Description: pkg.TableUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.TableUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/video/update.go b/cmd/video/update.go index 3f46410..4819759 100644 --- a/cmd/video/update.go +++ b/cmd/video/update.go @@ -4,7 +4,7 @@ package video import ( - "encoding/json" + "encoding/json/jsontext" "fmt" "io" "strings" @@ -52,7 +52,7 @@ var updateInSchema = &jsonschema.Schema{ "language": {Type: "string", Description: updateLangUsage}, "license": { Type: "string", Enum: []any{"youtube", "creativeCommon"}, - Description: licenseUsage, Default: json.RawMessage(`"youtube"`), + Description: licenseUsage, Default: jsontext.Value(`"youtube"`), }, "thumbnail": {Type: "string", Description: thumbnailUsage}, "playlist_id": {Type: "string", Description: pidUsage}, @@ -68,7 +68,7 @@ var updateInSchema = &jsonschema.Schema{ "confirmed": {Type: "boolean", Description: pkg.ConfirmedUsage}, "output": { Type: "string", Enum: []any{"json", "yaml", "silent"}, - Description: pkg.SilentUsage, Default: json.RawMessage(`"yaml"`), + Description: pkg.SilentUsage, Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/cmd/videoAbuseReportReason/list.go b/cmd/videoAbuseReportReason/list.go index 8a97b41..8209b0b 100644 --- a/cmd/videoAbuseReportReason/list.go +++ b/cmd/videoAbuseReportReason/list.go @@ -4,7 +4,7 @@ package videoAbuseReportReason import ( - "encoding/json" + "encoding/json/jsontext" "io" cobramcp "github.com/eat-pray-ai/cobra-mcp" @@ -33,12 +33,12 @@ var listInSchema = &jsonschema.Schema{ "parts": { Type: "array", Description: pkg.PartsUsage, Items: &jsonschema.Schema{Type: "string"}, - Default: json.RawMessage(`["id","snippet"]`), + Default: jsontext.Value(`["id","snippet"]`), }, "output": { Type: "string", Description: pkg.TableUsage, Enum: []any{"json", "yaml", "table"}, - Default: json.RawMessage(`"yaml"`), + Default: jsontext.Value(`"yaml"`), }, }, } diff --git a/pkg/abuseReport/abuseReport_test.go b/pkg/abuseReport/abuseReport_test.go index 41310cf..c7c95d5 100644 --- a/pkg/abuseReport/abuseReport_test.go +++ b/pkg/abuseReport/abuseReport_test.go @@ -5,7 +5,7 @@ package abuseReport import ( "bytes" - "encoding/json" + "encoding/json/v2" "net/http" "reflect" "testing" @@ -139,7 +139,7 @@ func TestAbuseReport_Insert(t *testing.T) { TypeId string `json:"typeId"` } `json:"subject"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } @@ -176,7 +176,7 @@ func TestAbuseReport_Insert(t *testing.T) { } `json:"entity"` } `json:"relatedEntities"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 49e60e1..35f2b1f 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -5,7 +5,7 @@ package auth import ( "context" - "encoding/json" + "encoding/json/v2" "fmt" "log/slog" "net" @@ -264,7 +264,7 @@ func (s *svc) saveToken(token *oauth2.Token) error { defer func() { _ = f.Close() }() - err = json.NewEncoder(f).Encode(token) + err = json.MarshalWrite(f, token) if err != nil { return fmt.Errorf("%s: %w", cacheTokenFailed, err) } diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 80e2704..211432c 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -5,7 +5,7 @@ package auth import ( "bytes" - "encoding/json" + "encoding/json/v2" "fmt" "net" "net/http" @@ -357,11 +357,16 @@ func TestGetCodeFromPrompt_ReadError(t *testing.T) { s := NewY2BService(WithIO(errReader, &out)).(*svc) - _, err := s.getCodeFromPrompt("http://example.com/auth", "http://localhost:8216") + _, err := s.getCodeFromPrompt( + "http://example.com/auth", "http://localhost:8216", + ) if err == nil { t.Fatalf("expected error from getCodeFromPrompt, got nil") } if !strings.Contains(err.Error(), "failed to read prompt") { - t.Errorf("expected error to contain %q, got %q", "failed to read prompt", err.Error()) + t.Errorf( + "expected error to contain %q, got %q", "failed to read prompt", + err.Error(), + ) } } diff --git a/pkg/auth/verifier.go b/pkg/auth/verifier.go index 6b2ab9e..56393cd 100644 --- a/pkg/auth/verifier.go +++ b/pkg/auth/verifier.go @@ -5,7 +5,7 @@ package auth import ( "context" - "encoding/json" + "encoding/json/v2" "fmt" "io" "net/http" @@ -48,7 +48,7 @@ func NewGoogleTokenVerifier(tokenInfoURL string) sdkauth.TokenVerifier { Sub string `json:"sub"` Error string `json:"error"` } - if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { + if err := json.UnmarshalRead(resp.Body, &result); err != nil { return nil, fmt.Errorf("%w: %w", sdkauth.ErrInvalidToken, err) } if result.Error != "" { diff --git a/pkg/auth/verifier_test.go b/pkg/auth/verifier_test.go index ef1b036..bb41b70 100644 --- a/pkg/auth/verifier_test.go +++ b/pkg/auth/verifier_test.go @@ -4,7 +4,7 @@ package auth import ( - "encoding/json" + "encoding/json/v2" "errors" "net/http" "net/http/httptest" @@ -14,19 +14,25 @@ import ( ) func TestGoogleTokenVerifier_ValidToken(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - token := r.URL.Query().Get("access_token") - if token != "valid-google-token" { - w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(map[string]string{"error": "invalid_token"}) - return - } - _ = json.NewEncoder(w).Encode(map[string]any{ - "expires_in": "3600", - "scope": "https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.channel-memberships.creator", - "sub": "user-123", - }) - })) + ts := httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + token := r.URL.Query().Get("access_token") + if token != "valid-google-token" { + w.WriteHeader(http.StatusBadRequest) + _ = json.MarshalWrite(w, map[string]string{"error": "invalid_token"}) + return + } + _ = json.MarshalWrite( + w, map[string]any{ + "expires_in": "3600", + "scope": "https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.channel-memberships.creator", + "sub": "user-123", + }, + ) + }, + ), + ) defer ts.Close() verifier := NewGoogleTokenVerifier(ts.URL) @@ -50,10 +56,14 @@ func TestGoogleTokenVerifier_ValidToken(t *testing.T) { } func TestGoogleTokenVerifier_InvalidToken(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(map[string]string{"error": "invalid_token"}) - })) + ts := httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusBadRequest) + _ = json.MarshalWrite(w, map[string]string{"error": "invalid_token"}) + }, + ), + ) defer ts.Close() verifier := NewGoogleTokenVerifier(ts.URL) @@ -67,9 +77,13 @@ func TestGoogleTokenVerifier_InvalidToken(t *testing.T) { } func TestGoogleTokenVerifier_ServerError(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusInternalServerError) - })) + ts := httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusInternalServerError) + }, + ), + ) defer ts.Close() verifier := NewGoogleTokenVerifier(ts.URL) diff --git a/pkg/liveBroadcast/liveBroadcast_test.go b/pkg/liveBroadcast/liveBroadcast_test.go index 14792c8..a908c65 100644 --- a/pkg/liveBroadcast/liveBroadcast_test.go +++ b/pkg/liveBroadcast/liveBroadcast_test.go @@ -5,7 +5,7 @@ package liveBroadcast import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "net/http" @@ -364,7 +364,7 @@ func TestLiveBroadcast_Insert(t *testing.T) { PrivacyStatus string `json:"privacyStatus"` } `json:"status"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } @@ -676,7 +676,7 @@ func TestLiveBroadcast_InsertCuepoint(t *testing.T) { CueType string `json:"cueType"` DurationSecs int64 `json:"durationSecs"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } if body.CueType != "cueTypeAd" { diff --git a/pkg/liveChatBan/liveChatBan_test.go b/pkg/liveChatBan/liveChatBan_test.go index 20fab87..e09e20b 100644 --- a/pkg/liveChatBan/liveChatBan_test.go +++ b/pkg/liveChatBan/liveChatBan_test.go @@ -5,7 +5,7 @@ package liveChatBan import ( "bytes" - "encoding/json" + "encoding/json/v2" "net/http" "reflect" "testing" @@ -151,7 +151,7 @@ func TestLiveChatBan_Insert(t *testing.T) { Type string `json:"type"` } `json:"snippet"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } @@ -190,7 +190,7 @@ func TestLiveChatBan_Insert(t *testing.T) { Type string `json:"type"` } `json:"snippet"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } diff --git a/pkg/liveChatMessage/liveChatMessage_test.go b/pkg/liveChatMessage/liveChatMessage_test.go index c0dc06a..7948f5c 100644 --- a/pkg/liveChatMessage/liveChatMessage_test.go +++ b/pkg/liveChatMessage/liveChatMessage_test.go @@ -5,7 +5,7 @@ package liveChatMessage import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "net/http" @@ -290,7 +290,7 @@ func TestLiveChatMessage_Insert(t *testing.T) { Type string `json:"type"` } `json:"snippet"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } diff --git a/pkg/liveChatModerator/liveChatModerator_test.go b/pkg/liveChatModerator/liveChatModerator_test.go index c172db1..598dd6a 100644 --- a/pkg/liveChatModerator/liveChatModerator_test.go +++ b/pkg/liveChatModerator/liveChatModerator_test.go @@ -5,7 +5,7 @@ package liveChatModerator import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "net/http" @@ -117,7 +117,9 @@ func TestNewLiveChatModerator(t *testing.T) { if got := NewLiveChatModerator(tt.args.opts...); !reflect.DeepEqual( got, tt.want, ) { - t.Errorf("%s\nNewLiveChatModerator() = %v\nwant %v", tt.name, got, tt.want) + t.Errorf( + "%s\nNewLiveChatModerator() = %v\nwant %v", tt.name, got, tt.want, + ) } }, ) @@ -186,11 +188,16 @@ func TestLiveChatModerator_Get(t *testing.T) { m := NewLiveChatModerator(opts...) got, err := m.Get() if (err != nil) != tt.wantErr { - t.Errorf("LiveChatModerator.Get() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "LiveChatModerator.Get() error = %v, wantErr %v", err, tt.wantErr, + ) return } if len(got) != tt.wantLen { - t.Errorf("LiveChatModerator.Get() got length = %v, want %v", len(got), tt.wantLen) + t.Errorf( + "LiveChatModerator.Get() got length = %v, want %v", len(got), + tt.wantLen, + ) } }, ) @@ -272,7 +279,7 @@ func TestLiveChatModerator_Insert(t *testing.T) { } `json:"moderatorDetails"` } `json:"snippet"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } diff --git a/pkg/liveStream/liveStream_test.go b/pkg/liveStream/liveStream_test.go index 38f868c..8271cc1 100644 --- a/pkg/liveStream/liveStream_test.go +++ b/pkg/liveStream/liveStream_test.go @@ -5,7 +5,7 @@ package liveStream import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "net/http" @@ -324,7 +324,7 @@ func TestLiveStream_Insert(t *testing.T) { Resolution string `json:"resolution"` } `json:"cdn"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } diff --git a/pkg/playlist/playlist_test.go b/pkg/playlist/playlist_test.go index 15e02f1..f23e529 100644 --- a/pkg/playlist/playlist_test.go +++ b/pkg/playlist/playlist_test.go @@ -5,7 +5,7 @@ package playlist import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "net/http" @@ -332,7 +332,8 @@ func TestPlaylist_Get_Pagination(t *testing.T) { } func TestPlaylist_List(t *testing.T) { - common.RunListTest(t, `{ + common.RunListTest( + t, `{ "items": [ { "id": "playlist-1", @@ -344,7 +345,9 @@ func TestPlaylist_List(t *testing.T) { ] }`, func(svc *youtube.Service, output string) func(io.Writer) error { - p := NewPlaylist(WithService(svc), WithOutput(output), WithIds([]string{"playlist-1"})) + p := NewPlaylist( + WithService(svc), WithOutput(output), WithIds([]string{"playlist-1"}), + ) return p.List }, ) @@ -459,7 +462,7 @@ func TestPlaylist_Update(t *testing.T) { } var playlist youtube.Playlist - if err := json.NewDecoder(r.Body).Decode(&playlist); err != nil { + if err := json.UnmarshalRead(r.Body, &playlist); err != nil { t.Errorf("failed to decode body: %v", err) } if playlist.Snippet.Title != "Updated Title" { diff --git a/pkg/subscription/subscription_test.go b/pkg/subscription/subscription_test.go index 7b15b9a..4ce9a90 100644 --- a/pkg/subscription/subscription_test.go +++ b/pkg/subscription/subscription_test.go @@ -5,7 +5,7 @@ package subscription import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "net/http" @@ -331,7 +331,8 @@ func TestSubscription_Get_Pagination(t *testing.T) { } func TestSubscription_List(t *testing.T) { - common.RunListTest(t, `{ + common.RunListTest( + t, `{ "items": [ { "id": "sub-1", @@ -346,7 +347,9 @@ func TestSubscription_List(t *testing.T) { ] }`, func(svc *youtube.Service, output string) func(io.Writer) error { - s := NewSubscription(WithService(svc), WithOutput(output), WithIds([]string{"sub-1"})) + s := NewSubscription( + WithService(svc), WithOutput(output), WithIds([]string{"sub-1"}), + ) return s.List }, ) @@ -385,7 +388,7 @@ func TestSubscription_Insert(t *testing.T) { ChannelId string `json:"channelId"` } `json:"snippet"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } diff --git a/pkg/thirdPartyLink/thirdPartyLink_test.go b/pkg/thirdPartyLink/thirdPartyLink_test.go index 9a6d487..143d565 100644 --- a/pkg/thirdPartyLink/thirdPartyLink_test.go +++ b/pkg/thirdPartyLink/thirdPartyLink_test.go @@ -5,7 +5,7 @@ package thirdPartyLink import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "net/http" "reflect" @@ -79,7 +79,9 @@ func TestNewThirdPartyLink(t *testing.T) { if got := NewThirdPartyLink(tt.args.opts...); !reflect.DeepEqual( got, tt.want, ) { - t.Errorf("%s\nNewThirdPartyLink() = %v\nwant %v", tt.name, got, tt.want) + t.Errorf( + "%s\nNewThirdPartyLink() = %v\nwant %v", tt.name, got, tt.want, + ) } }, ) @@ -102,7 +104,10 @@ func TestThirdPartyLink_Get(t *testing.T) { }, verify: func(r *http.Request) { if r.URL.Query().Get("linkingToken") != "token123" { - t.Errorf("expected linkingToken=token123, got %s", r.URL.Query().Get("linkingToken")) + t.Errorf( + "expected linkingToken=token123, got %s", + r.URL.Query().Get("linkingToken"), + ) } }, wantLen: 1, @@ -116,7 +121,9 @@ func TestThirdPartyLink_Get(t *testing.T) { }, verify: func(r *http.Request) { if r.URL.Query().Get("type") != "channelToStoreLink" { - t.Errorf("expected type=channelToStoreLink, got %s", r.URL.Query().Get("type")) + t.Errorf( + "expected type=channelToStoreLink, got %s", r.URL.Query().Get("type"), + ) } }, wantLen: 1, @@ -130,7 +137,10 @@ func TestThirdPartyLink_Get(t *testing.T) { }, verify: func(r *http.Request) { if r.URL.Query().Get("externalChannelId") != "ext-channel-123" { - t.Errorf("expected externalChannelId=ext-channel-123, got %s", r.URL.Query().Get("externalChannelId")) + t.Errorf( + "expected externalChannelId=ext-channel-123, got %s", + r.URL.Query().Get("externalChannelId"), + ) } }, wantLen: 1, @@ -163,11 +173,15 @@ func TestThirdPartyLink_Get(t *testing.T) { tpl := NewThirdPartyLink(opts...) got, err := tpl.Get() if (err != nil) != tt.wantErr { - t.Errorf("ThirdPartyLink.Get() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "ThirdPartyLink.Get() error = %v, wantErr %v", err, tt.wantErr, + ) return } if len(got) != tt.wantLen { - t.Errorf("ThirdPartyLink.Get() got length = %v, want %v", len(got), tt.wantLen) + t.Errorf( + "ThirdPartyLink.Get() got length = %v, want %v", len(got), tt.wantLen, + ) } }, ) @@ -175,7 +189,8 @@ func TestThirdPartyLink_Get(t *testing.T) { } func TestThirdPartyLink_List(t *testing.T) { - common.RunListTest(t, `{ + common.RunListTest( + t, `{ "items": [ { "linkingToken": "token123", @@ -225,7 +240,7 @@ func TestThirdPartyLink_Insert(t *testing.T) { LinkStatus string `json:"linkStatus"` } `json:"status"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } @@ -233,10 +248,14 @@ func TestThirdPartyLink_Insert(t *testing.T) { t.Errorf("expected linkingToken=token123, got %s", body.LinkingToken) } if body.Snippet.Type != "channelToStoreLink" { - t.Errorf("expected snippet.type=channelToStoreLink, got %s", body.Snippet.Type) + t.Errorf( + "expected snippet.type=channelToStoreLink, got %s", body.Snippet.Type, + ) } if body.Status.LinkStatus != "pending" { - t.Errorf("expected status.linkStatus=pending, got %s", body.Status.LinkStatus) + t.Errorf( + "expected status.linkStatus=pending, got %s", body.Status.LinkStatus, + ) } }, wantErr: false, @@ -262,7 +281,9 @@ func TestThirdPartyLink_Insert(t *testing.T) { tpl := NewThirdPartyLink(opts...) var buf bytes.Buffer if err := tpl.Insert(&buf); (err != nil) != tt.wantErr { - t.Errorf("ThirdPartyLink.Insert() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "ThirdPartyLink.Insert() error = %v, wantErr %v", err, tt.wantErr, + ) } }, ) @@ -296,7 +317,7 @@ func TestThirdPartyLink_Update(t *testing.T) { LinkStatus string `json:"linkStatus"` } `json:"status"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode request body: %v", err) } @@ -304,7 +325,9 @@ func TestThirdPartyLink_Update(t *testing.T) { t.Errorf("expected linkingToken=token123, got %s", body.LinkingToken) } if body.Status.LinkStatus != "linked" { - t.Errorf("expected status.linkStatus=linked, got %s", body.Status.LinkStatus) + t.Errorf( + "expected status.linkStatus=linked, got %s", body.Status.LinkStatus, + ) } }, wantErr: false, @@ -319,11 +342,13 @@ func TestThirdPartyLink_Update(t *testing.T) { func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") if r.Method == "GET" { - _, _ = w.Write([]byte(`{ + _, _ = w.Write( + []byte(`{ "items": [ {"linkingToken": "token123", "snippet": {"type": "channelToStoreLink"}, "status": {"linkStatus": "pending"}} ] - }`)) + }`), + ) return } if tt.verify != nil { @@ -338,7 +363,9 @@ func TestThirdPartyLink_Update(t *testing.T) { tpl := NewThirdPartyLink(opts...) var buf bytes.Buffer if err := tpl.Update(&buf); (err != nil) != tt.wantErr { - t.Errorf("ThirdPartyLink.Update() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "ThirdPartyLink.Update() error = %v, wantErr %v", err, tt.wantErr, + ) } }, ) @@ -363,10 +390,15 @@ func TestThirdPartyLink_Delete(t *testing.T) { t.Errorf("expected DELETE, got %s", r.Method) } if r.URL.Query().Get("linkingToken") != "token123" { - t.Errorf("expected linkingToken=token123, got %s", r.URL.Query().Get("linkingToken")) + t.Errorf( + "expected linkingToken=token123, got %s", + r.URL.Query().Get("linkingToken"), + ) } if r.URL.Query().Get("type") != "channelToStoreLink" { - t.Errorf("expected type=channelToStoreLink, got %s", r.URL.Query().Get("type")) + t.Errorf( + "expected type=channelToStoreLink, got %s", r.URL.Query().Get("type"), + ) } }, wantErr: false, @@ -391,7 +423,9 @@ func TestThirdPartyLink_Delete(t *testing.T) { tpl := NewThirdPartyLink(opts...) var buf bytes.Buffer if err := tpl.Delete(&buf); (err != nil) != tt.wantErr { - t.Errorf("ThirdPartyLink.Delete() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "ThirdPartyLink.Delete() error = %v, wantErr %v", err, tt.wantErr, + ) } }, ) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index f14d568..bc5803d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -7,7 +7,8 @@ import ( "bufio" "crypto/rand" "encoding/base64" - "encoding/json" + "encoding/json/jsontext" + "encoding/json/v2" "errors" "fmt" "io" @@ -39,7 +40,7 @@ var IsInteractive = func(v any) bool { func PrintJSON(data any, writer io.Writer) { var marshalled []byte if IsInteractive(writer) { - marshalled, _ = json.MarshalIndent(data, "", " ") + marshalled, _ = json.Marshal(data, jsontext.WithIndent(" ")) } else { marshalled, _ = json.Marshal(data) } @@ -81,7 +82,7 @@ func GetFileName(file string) string { } func IsJson(s string) bool { - var js json.RawMessage + var js jsontext.Value return json.Unmarshal([]byte(s), &js) == nil } diff --git a/pkg/video/video_test.go b/pkg/video/video_test.go index 1b87bf3..3e976ff 100644 --- a/pkg/video/video_test.go +++ b/pkg/video/video_test.go @@ -5,7 +5,7 @@ package video import ( "bytes" - "encoding/json" + "encoding/json/v2" "io" "math" "mime" @@ -546,7 +546,7 @@ func TestVideo_Insert(t *testing.T) { defer func() { _ = part.Close() }() var body youtube.Video - if err := json.NewDecoder(part).Decode(&body); err != nil { + if err := json.UnmarshalRead(part, &body); err != nil { t.Fatalf("failed to decode video from request body: %v", err) } return &body @@ -650,11 +650,17 @@ func TestVideo_Insert(t *testing.T) { t.Errorf("expected POST, got %s", r.Method) } if !strings.Contains(r.URL.Query().Get("part"), "recordingDetails") { - t.Errorf("expected part to contain recordingDetails, got %s", r.URL.Query().Get("part")) + t.Errorf( + "expected part to contain recordingDetails, got %s", + r.URL.Query().Get("part"), + ) } body := decodeMultipartVideo(t, r) if body.RecordingDetails == nil || body.RecordingDetails.RecordingDate != "2024-06-15T10:00:00Z" { - t.Errorf("expected recordingDetails.recordingDate=2024-06-15T10:00:00Z, got %+v", body.RecordingDetails) + t.Errorf( + "expected recordingDetails.recordingDate=2024-06-15T10:00:00Z, got %+v", + body.RecordingDetails, + ) } if body.Status == nil || !body.Status.SelfDeclaredMadeForKids { t.Errorf("expected status.selfDeclaredMadeForKids=true") @@ -683,7 +689,10 @@ func TestVideo_Insert(t *testing.T) { } body := decodeMultipartVideo(t, r) if body.Snippet == nil || body.Snippet.Title != "test_video" { - t.Errorf("expected snippet.title=test_video (from filename), got %+v", body.Snippet) + t.Errorf( + "expected snippet.title=test_video (from filename), got %+v", + body.Snippet, + ) } }, wantErr: false, @@ -708,7 +717,10 @@ func TestVideo_Insert(t *testing.T) { } } if count != 1 { - t.Errorf("expected exactly 1 yutu🐰 tag, got %d in %v", count, body.Snippet.Tags) + t.Errorf( + "expected exactly 1 yutu🐰 tag, got %d in %v", count, + body.Snippet.Tags, + ) } }, wantErr: false, @@ -725,7 +737,9 @@ func TestVideo_Insert(t *testing.T) { defer func() { pkg.Root = oldRoot }() defer func() { _ = root.Close() }() - err = os.WriteFile(tmpDir+"/test_video.mp4", []byte("dummy video content"), 0644) + err = os.WriteFile( + tmpDir+"/test_video.mp4", []byte("dummy video content"), 0644, + ) if err != nil { t.Fatalf("failed to create dummy file: %v", err) } @@ -814,7 +828,7 @@ func TestVideo_Update(t *testing.T) { } var body youtube.Video - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode update body: %v", err) } if body.Id != "video-id" { @@ -871,20 +885,27 @@ func TestVideo_Update(t *testing.T) { verify: func(r *http.Request) { if r.Method == "PUT" { var body youtube.Video - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode update body: %v", err) } if body.Snippet.DefaultLanguage != "ja" { - t.Errorf("expected defaultLanguage=ja, got %s", body.Snippet.DefaultLanguage) + t.Errorf( + "expected defaultLanguage=ja, got %s", body.Snippet.DefaultLanguage, + ) } if body.Status.License != "creativeCommon" { - t.Errorf("expected license=creativeCommon, got %s", body.Status.License) + t.Errorf( + "expected license=creativeCommon, got %s", body.Status.License, + ) } if body.Snippet.CategoryId != "22" { t.Errorf("expected categoryId=22, got %s", body.Snippet.CategoryId) } if body.Status.PrivacyStatus != "unlisted" { - t.Errorf("expected privacyStatus=unlisted, got %s", body.Status.PrivacyStatus) + t.Errorf( + "expected privacyStatus=unlisted, got %s", + body.Status.PrivacyStatus, + ) } found := false for _, tag := range body.Snippet.Tags { @@ -910,14 +931,20 @@ func TestVideo_Update(t *testing.T) { verify: func(r *http.Request) { if r.Method == "PUT" { var body youtube.Video - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode update body: %v", err) } if body.Status.PublishAt != "2026-08-18T15:00:00Z" { - t.Errorf("expected publishAt=2026-08-18T15:00:00Z, got %s", body.Status.PublishAt) + t.Errorf( + "expected publishAt=2026-08-18T15:00:00Z, got %s", + body.Status.PublishAt, + ) } if body.Status.PrivacyStatus != "private" { - t.Errorf("expected privacyStatus=private when scheduling, got %s", body.Status.PrivacyStatus) + t.Errorf( + "expected privacyStatus=private when scheduling, got %s", + body.Status.PrivacyStatus, + ) } } }, @@ -935,14 +962,20 @@ func TestVideo_Update(t *testing.T) { verify: func(r *http.Request) { if r.Method == "PUT" { var body youtube.Video - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode update body: %v", err) } if body.Status.PublishAt != "2026-08-18T15:00:00Z" { - t.Errorf("expected publishAt=2026-08-18T15:00:00Z, got %s", body.Status.PublishAt) + t.Errorf( + "expected publishAt=2026-08-18T15:00:00Z, got %s", + body.Status.PublishAt, + ) } if body.Status.PrivacyStatus != "private" { - t.Errorf("expected privacyStatus=private when scheduling, got %s", body.Status.PrivacyStatus) + t.Errorf( + "expected privacyStatus=private when scheduling, got %s", + body.Status.PrivacyStatus, + ) } } }, @@ -991,10 +1024,13 @@ func TestVideo_Update(t *testing.T) { verify: func(r *http.Request) { if r.Method == "PUT" { if !strings.Contains(r.URL.Query().Get("part"), "recordingDetails") { - t.Errorf("expected part to contain recordingDetails, got %s", r.URL.Query().Get("part")) + t.Errorf( + "expected part to contain recordingDetails, got %s", + r.URL.Query().Get("part"), + ) } var body youtube.Video - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + if err := json.UnmarshalRead(r.Body, &body); err != nil { t.Fatalf("failed to decode update body: %v", err) } if !body.Status.Embeddable { @@ -1004,7 +1040,10 @@ func TestVideo_Update(t *testing.T) { t.Errorf("expected containsSyntheticMedia=true") } if body.RecordingDetails == nil || body.RecordingDetails.RecordingDate != "2024-01-01T00:00:00Z" { - t.Errorf("expected recordingDate=2024-01-01T00:00:00Z, got %+v", body.RecordingDetails) + t.Errorf( + "expected recordingDate=2024-01-01T00:00:00Z, got %+v", + body.RecordingDetails, + ) } } },