diff --git a/codersdk/toolsdk/toolsdk.go b/codersdk/toolsdk/toolsdk.go index 024e3bad6efdc..166bde730efc5 100644 --- a/codersdk/toolsdk/toolsdk.go +++ b/codersdk/toolsdk/toolsdk.go @@ -327,6 +327,7 @@ var ListWorkspaces = Tool[ListWorkspacesArgs, []MinimalWorkspace]{ "description": "The owner of the workspaces to list. Use \"me\" to list workspaces for the authenticated user. If you do not specify an owner, \"me\" will be assumed by default.", }, }, + Required: []string{}, }, }, Handler: func(ctx context.Context, deps Deps, args ListWorkspacesArgs) ([]MinimalWorkspace, error) { @@ -1256,6 +1257,7 @@ var DeleteTemplate = Tool[DeleteTemplateArgs, codersdk.Response]{ "type": "string", }, }, + Required: []string{"template_id"}, }, }, Handler: func(ctx context.Context, deps Deps, args DeleteTemplateArgs) (codersdk.Response, error) { diff --git a/codersdk/toolsdk/toolsdk_test.go b/codersdk/toolsdk/toolsdk_test.go index fae4e85e52a66..f9c35dba5951d 100644 --- a/codersdk/toolsdk/toolsdk_test.go +++ b/codersdk/toolsdk/toolsdk_test.go @@ -539,6 +539,33 @@ func TestWithCleanContext(t *testing.T) { }) } +func TestToolSchemaFields(t *testing.T) { + t.Parallel() + + // Test that all tools have the required Schema fields (Properties and Required) + for _, tool := range toolsdk.All { + t.Run(tool.Tool.Name, func(t *testing.T) { + t.Parallel() + + // Check that Properties is not nil + require.NotNil(t, tool.Tool.Schema.Properties, + "Tool %q missing Schema.Properties", tool.Tool.Name) + + // Check that Required is not nil + require.NotNil(t, tool.Tool.Schema.Required, + "Tool %q missing Schema.Required", tool.Tool.Name) + + // Ensure Properties has entries for all required fields + for _, requiredField := range tool.Tool.Schema.Required { + _, exists := tool.Tool.Schema.Properties[requiredField] + require.True(t, exists, + "Tool %q requires field %q but it is not defined in Properties", + tool.Tool.Name, requiredField) + } + }) + } +} + // TestMain runs after all tests to ensure that all tools in this package have // been tested once. func TestMain(m *testing.M) {