Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | /** |
| 2 | * Json-schema-to-zod Example |
| 3 | * |
| 4 | * This example demonstrates how to use Composio SDK for json-schema-to-zod. |
| 5 | * |
| 6 | * Prerequisites: |
| 7 | * 1. Set up your COMPOSIO_API_KEY in the .env file |
| 8 | * 3. Run the example: pnpm start |
| 9 | */ |
| 10 | |
| 11 | import { Composio, jsonSchemaToZodSchema } from '@composio/core'; |
| 12 | import { zodToJsonSchema } from 'zod-to-json-schema'; |
| 13 | import 'dotenv/config'; |
| 14 | |
| 15 | /** |
| 16 | * Initialize Composio |
| 17 | */ |
| 18 | const composio = new Composio({ |
| 19 | apiKey: process.env.COMPOSIO_API_KEY, |
| 20 | }); |
| 21 | |
| 22 | /** |
| 23 | * Main function to run the example |
| 24 | */ |
| 25 | async function main() { |
| 26 | try { |
| 27 | console.log('🚀 Starting Json-schema-to-zod Example...'); |
| 28 | |
| 29 | // Get available tools |
| 30 | const tool = await composio.tools.getRawComposioToolBySlug('GOOGLECALENDAR_PATCH_EVENT'); |
| 31 | |
| 32 | console.log(JSON.stringify(tool.inputParameters, null, 2)); |
| 33 | |
| 34 | const zodSchema = jsonSchemaToZodSchema(tool.inputParameters ?? {}); |
| 35 | |
| 36 | console.log(JSON.stringify(zodToJsonSchema(zodSchema), null, 2)); |
| 37 | // TODO: Add your example implementation here |
| 38 | console.log('📝 Implement your json-schema-to-zod logic here!'); |
| 39 | } catch (error) { |
| 40 | console.error('❌ Error running example:', error); |
| 41 | process.exitCode = 1; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // Run the example |
| 46 | main().catch(error => { |
| 47 | console.error(error); |
| 48 | process.exitCode = 1; |
| 49 | }); |