Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix zodschema parsing (#1801)

Musthaq Ahamaddc87f401ce1d
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1c170bed3..fb1728d88 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -285,6 +285,9 @@ importers:
'@composio/core':
specifier: workspace:*
version: link:../../packages/core
+ '@composio/vercel':
+ specifier: workspace:^
+ version: link:../../packages/providers/vercel
dotenv:
specifier: ^16.4.1
version: 16.5.0
@@ -603,8 +606,8 @@ importers:
specifier: 0.1.0-alpha.29
version: 0.1.0-alpha.29
'@composio/json-schema-to-zod':
- specifier: 0.1.10
- version: 0.1.10
+ specifier: 0.1.11
+ version: 0.1.11
'@types/json-schema':
specifier: ^7.0.15
version: 7.0.15
@@ -1156,8 +1159,8 @@ packages:
'@composio/[email protected]':
resolution: {integrity: sha512-0oI38Kl8LVEK/fFF7rTdvO11uwSWHzavTTUWE/ExnhIoik3wmHse1CRKywb06M+hkLO4+Vdkh46sXbNFs7YZyQ==}
- '@composio/[email protected]':
- resolution: {integrity: sha512-U+sdd+/+C6TDXeljXEN7pJ4YjH2Tda8U1S7S0ceXyZt5lF2YQIxE6YYKAdcV0ojUUfL7Mwsmbe8va3rDOud1pA==}
+ '@composio/[email protected]':
+ resolution: {integrity: sha512-6gcCof9xqLhmmHSCvWLW/E16PKr5C1dWJ9AOk4FJU8JA7gSt8JEdFHBwx80dyprBJdwPF6R54nlkmpXrEwApzg==}
'@composio/[email protected]':
resolution: {integrity: sha512-IpbfST0SSs/CEv+PIf6+EL0feNuJhQyUrOHJLPge8NhyLLrCyVqvujRIPyRUUjy0NDsked/Mm5VpJmYM6OACbg==}
@@ -7169,7 +7172,7 @@ snapshots:
'@composio/[email protected]': {}
- '@composio/[email protected]':
+ '@composio/[email protected]':
dependencies:
'@types/json-schema': 7.0.15
zod: 3.25.67
@@ -9616,14 +9619,6 @@ snapshots:
chai: 5.2.0
tinyrainbow: 2.0.0
- dependencies:
- '@vitest/spy': 3.2.4
- estree-walker: 3.0.3
- magic-string: 0.30.17
- optionalDependencies:
-
dependencies:
'@vitest/spy': 3.2.4
@@ -9632,14 +9627,6 @@ snapshots:
optionalDependencies:
- dependencies:
- '@vitest/spy': 3.2.4
- estree-walker: 3.0.3
- magic-string: 0.30.17
- optionalDependencies:
-
'@vitest/[email protected]':
dependencies:
tinyrainbow: 2.0.0
@@ -9669,7 +9656,7 @@ snapshots:
sirv: 3.0.1
tinyglobby: 0.2.14
tinyrainbow: 2.0.0
'@vitest/[email protected]':
dependencies:
@@ -12733,7 +12720,7 @@ snapshots:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.4
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
@@ -12817,7 +12804,7 @@ snapshots:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.4
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
diff --git a/ts/examples/json-schema-to-zod/package.json b/ts/examples/json-schema-to-zod/package.json
index db1df2a40..9d2fb14db 100644
--- a/ts/examples/json-schema-to-zod/package.json
+++ b/ts/examples/json-schema-to-zod/package.json
@@ -20,6 +20,7 @@
"packageManager": "[email protected]",
"dependencies": {
"@composio/core": "workspace:*",
+ "@composio/vercel": "workspace:^",
"dotenv": "^16.4.1",
"zod-to-json-schema": "^3.24.5"
},
diff --git a/ts/packages/core/CHANGELOG.md b/ts/packages/core/CHANGELOG.md
index 0e2e99012..f3911afcf 100644
--- a/ts/packages/core/CHANGELOG.md
+++ b/ts/packages/core/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/core
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/core/package.json b/ts/packages/core/package.json
index 8c9d6be78..b65edb56f 100644
--- a/ts/packages/core/package.json
+++ b/ts/packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/core",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "",
"main": "src/index.ts",
"type": "module",
@@ -45,7 +45,7 @@
},
"dependencies": {
"@composio/client": "0.1.0-alpha.29",
- "@composio/json-schema-to-zod": "0.1.10",
+ "@composio/json-schema-to-zod": "0.1.11",
"@types/json-schema": "^7.0.15",
"chalk": "^4.1.2",
"openai": "^4.94.0",
diff --git a/ts/packages/json-schema-to-zod/CHANGELOG.md b/ts/packages/json-schema-to-zod/CHANGELOG.md
index ab5be566b..b965a9881 100644
--- a/ts/packages/json-schema-to-zod/CHANGELOG.md
+++ b/ts/packages/json-schema-to-zod/CHANGELOG.md
@@ -1,5 +1,11 @@
# @composio/json-schema-to-zod
+## 0.1.11
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+
## 0.1.10
### Patch Changes
diff --git a/ts/packages/json-schema-to-zod/package.json b/ts/packages/json-schema-to-zod/package.json
index 4529a018e..2c351794b 100644
--- a/ts/packages/json-schema-to-zod/package.json
+++ b/ts/packages/json-schema-to-zod/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/json-schema-to-zod",
- "version": "0.1.10",
+ "version": "0.1.11",
"description": "",
"main": "src/index.ts",
"type": "module",
diff --git a/ts/packages/json-schema-to-zod/src/parsers/parse-array.ts b/ts/packages/json-schema-to-zod/src/parsers/parse-array.ts
index ce69d8b0a..1164fd6ec 100644
--- a/ts/packages/json-schema-to-zod/src/parsers/parse-array.ts
+++ b/ts/packages/json-schema-to-zod/src/parsers/parse-array.ts
@@ -83,5 +83,31 @@ export const parseArray = (jsonSchema: JsonSchemaObject & { type: 'array' }, ref
(zs, maxItems, errorMessage) => zs.max(maxItems, errorMessage)
);
+ // Handle generic 'min' property as alias for 'minItems'
+ if (
+ typeof (jsonSchema as unknown as { min?: number }).min === 'number' &&
+ typeof jsonSchema.minItems !== 'number'
+ ) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ { ...jsonSchema, minItems: (jsonSchema as unknown as { min?: number }).min },
+ 'minItems',
+ (zs, minItems, errorMessage) => zs.min(minItems, errorMessage)
+ );
+ }
+
+ // Handle generic 'max' property as alias for 'maxItems'
+ if (
+ typeof (jsonSchema as unknown as { max?: number }).max === 'number' &&
+ typeof jsonSchema.maxItems !== 'number'
+ ) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ { ...jsonSchema, maxItems: (jsonSchema as unknown as { max?: number }).max },
+ 'maxItems',
+ (zs, maxItems, errorMessage) => zs.max(maxItems, errorMessage)
+ );
+ }
+
return zodSchema;
};
diff --git a/ts/packages/json-schema-to-zod/src/parsers/parse-number.ts b/ts/packages/json-schema-to-zod/src/parsers/parse-number.ts
index 504a453fa..dc4d12e84 100644
--- a/ts/packages/json-schema-to-zod/src/parsers/parse-number.ts
+++ b/ts/packages/json-schema-to-zod/src/parsers/parse-number.ts
@@ -4,85 +4,111 @@ import type { JsonSchemaObject } from '../types';
import { extendSchemaWithMessage } from '../utils/extend-schema';
export const parseNumber = (jsonSchema: JsonSchemaObject & { type: 'number' | 'integer' }) => {
- let zodSchema = z.number();
+ let zodSchema = z.number();
- let isInteger = false;
- if (jsonSchema.type === 'integer') {
- isInteger = true;
- zodSchema = extendSchemaWithMessage(zodSchema, jsonSchema, 'type', (zs, _, errorMsg) =>
- zs.int(errorMsg),
- );
- } else if (jsonSchema.format === 'int64') {
- isInteger = true;
- zodSchema = extendSchemaWithMessage(zodSchema, jsonSchema, 'format', (zs, _, errorMsg) =>
- zs.int(errorMsg),
- );
- }
+ let isInteger = false;
+ if (jsonSchema.type === 'integer') {
+ isInteger = true;
+ zodSchema = extendSchemaWithMessage(zodSchema, jsonSchema, 'type', (zs, _, errorMsg) =>
+ zs.int(errorMsg)
+ );
+ } else if (jsonSchema.format === 'int64') {
+ isInteger = true;
+ zodSchema = extendSchemaWithMessage(zodSchema, jsonSchema, 'format', (zs, _, errorMsg) =>
+ zs.int(errorMsg)
+ );
+ }
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'multipleOf',
- (zs, multipleOf, errorMsg) => {
- if (multipleOf === 1) {
- if (isInteger) return zs;
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'multipleOf',
+ (zs, multipleOf, errorMsg) => {
+ if (multipleOf === 1) {
+ if (isInteger) return zs;
- return zs.int(errorMsg);
- }
+ return zs.int(errorMsg);
+ }
- return zs.multipleOf(multipleOf, errorMsg);
- },
- );
+ return zs.multipleOf(multipleOf, errorMsg);
+ }
+ );
- if (typeof jsonSchema.minimum === 'number') {
- if (jsonSchema.exclusiveMinimum === true) {
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'minimum',
- (zs, minimum, errorMsg) => zs.gt(minimum, errorMsg),
- );
- } else {
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'minimum',
- (zs, minimum, errorMsg) => zs.gte(minimum, errorMsg),
- );
- }
- } else if (typeof jsonSchema.exclusiveMinimum === 'number') {
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'exclusiveMinimum',
- (zs, exclusiveMinimum, errorMsg) => zs.gt(exclusiveMinimum as number, errorMsg),
- );
- }
+ if (typeof jsonSchema.minimum === 'number') {
+ if ((jsonSchema as unknown as { exclusiveMinimum?: boolean }).exclusiveMinimum === true) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'minimum',
+ (zs, minimum, errorMsg) => zs.gt(minimum, errorMsg)
+ );
+ } else {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'minimum',
+ (zs, minimum, errorMsg) => zs.gte(minimum, errorMsg)
+ );
+ }
+ } else if (typeof jsonSchema.exclusiveMinimum === 'number') {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'exclusiveMinimum',
+ (zs, exclusiveMinimum, errorMsg) => zs.gt(exclusiveMinimum as number, errorMsg)
+ );
+ }
- if (typeof jsonSchema.maximum === 'number') {
- if (jsonSchema.exclusiveMaximum === true) {
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'maximum',
- (zs, maximum, errorMsg) => zs.lt(maximum, errorMsg),
- );
- } else {
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'maximum',
- (zs, maximum, errorMsg) => zs.lte(maximum, errorMsg),
- );
- }
- } else if (typeof jsonSchema.exclusiveMaximum === 'number') {
- zodSchema = extendSchemaWithMessage(
- zodSchema,
- jsonSchema,
- 'exclusiveMaximum',
- (zs, exclusiveMaximum, errorMsg) => zs.lt(exclusiveMaximum as number, errorMsg),
- );
- }
+ if (typeof jsonSchema.maximum === 'number') {
+ if ((jsonSchema as unknown as { exclusiveMaximum?: boolean }).exclusiveMaximum === true) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'maximum',
+ (zs, maximum, errorMsg) => zs.lt(maximum, errorMsg)
+ );
+ } else {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'maximum',
+ (zs, maximum, errorMsg) => zs.lte(maximum, errorMsg)
+ );
+ }
+ } else if (typeof jsonSchema.exclusiveMaximum === 'number') {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ jsonSchema,
+ 'exclusiveMaximum',
+ (zs, exclusiveMaximum, errorMsg) => zs.lt(exclusiveMaximum as number, errorMsg)
+ );
+ }
- return zodSchema;
+ // Handle generic 'min' property as alias for 'minimum'
+ if (
+ typeof (jsonSchema as unknown as { min?: number }).min === 'number' &&
+ typeof jsonSchema.minimum !== 'number'
+ ) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ { ...jsonSchema, minimum: (jsonSchema as unknown as { min?: number }).min },
+ 'minimum',
+ (zs, minimum, errorMsg) => zs.gte(minimum, errorMsg)
+ );
+ }
+
+ // Handle generic 'max' property as alias for 'maximum'
+ if (
+ typeof (jsonSchema as unknown as { max?: number }).max === 'number' &&
+ typeof jsonSchema.maximum !== 'number'
+ ) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ { ...jsonSchema, maximum: (jsonSchema as unknown as { max?: number }).max },
+ 'maximum',
+ (zs, maximum, errorMsg) => zs.lte(maximum, errorMsg)
+ );
+ }
+
+ return zodSchema;
};
diff --git a/ts/packages/json-schema-to-zod/src/parsers/parse-schema.ts b/ts/packages/json-schema-to-zod/src/parsers/parse-schema.ts
index 3af49761a..09bfac618 100644
--- a/ts/packages/json-schema-to-zod/src/parsers/parse-schema.ts
+++ b/ts/packages/json-schema-to-zod/src/parsers/parse-schema.ts
@@ -20,10 +20,34 @@ import type { ParserSelector, Refs, JsonSchemaObject, JsonSchema } from '../type
import { its } from '../utils/its';
const addDescribes = (jsonSchema: JsonSchemaObject, zodSchema: z.ZodTypeAny): z.ZodTypeAny => {
+ let description = '';
+
if (jsonSchema.description) {
- zodSchema = zodSchema.describe(jsonSchema.description);
+ description = jsonSchema.description;
} else if (jsonSchema.title) {
- zodSchema = zodSchema.describe(jsonSchema.title);
+ description = jsonSchema.title;
+ }
+
+ // Append example(s) if they exist
+ if ((jsonSchema as unknown as { example?: unknown }).example !== undefined) {
+ const exampleText = `Example: ${JSON.stringify((jsonSchema as unknown as { example?: unknown }).example)}`;
+ description = description ? `${description}\n${exampleText}` : exampleText;
+ } else if (
+ (jsonSchema as unknown as { examples?: unknown[] }).examples !== undefined &&
+ Array.isArray((jsonSchema as unknown as { examples?: unknown[] }).examples)
+ ) {
+ const examples = (jsonSchema as unknown as { examples?: unknown[] }).examples;
+ if (examples && examples.length && examples.length > 0) {
+ const exampleText =
+ examples.length === 1
+ ? `Example: ${JSON.stringify(examples[0])}`
+ : `Examples:\n${examples.map((ex: unknown) => ` ${JSON.stringify(ex)}`).join('\n')}`;
+ description = description ? `${description}\n${exampleText}` : exampleText;
+ }
+ }
+
+ if (description) {
+ zodSchema = zodSchema.describe(description);
}
return zodSchema;
diff --git a/ts/packages/json-schema-to-zod/src/parsers/parse-string.ts b/ts/packages/json-schema-to-zod/src/parsers/parse-string.ts
index c8e587112..f31a1abba 100644
--- a/ts/packages/json-schema-to-zod/src/parsers/parse-string.ts
+++ b/ts/packages/json-schema-to-zod/src/parsers/parse-string.ts
@@ -54,5 +54,31 @@ export const parseString = (jsonSchema: JsonSchemaObject & { type: 'string' }) =
(zs, maxLength, errorMsg) => zs.max(maxLength, errorMsg)
);
+ // Handle generic 'min' property as alias for 'minLength'
+ if (
+ typeof (jsonSchema as unknown as { min?: number }).min === 'number' &&
+ typeof jsonSchema.minLength !== 'number'
+ ) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ { ...jsonSchema, minLength: (jsonSchema as unknown as { min?: number }).min },
+ 'minLength',
+ (zs, minLength, errorMsg) => zs.min(minLength, errorMsg)
+ );
+ }
+
+ // Handle generic 'max' property as alias for 'maxLength'
+ if (
+ typeof (jsonSchema as unknown as { max?: number }).max === 'number' &&
+ typeof jsonSchema.maxLength !== 'number'
+ ) {
+ zodSchema = extendSchemaWithMessage(
+ zodSchema,
+ { ...jsonSchema, maxLength: (jsonSchema as unknown as { max?: number }).max },
+ 'maxLength',
+ (zs, maxLength, errorMsg) => zs.max(maxLength, errorMsg)
+ );
+ }
+
return zodSchema;
};
diff --git a/ts/packages/json-schema-to-zod/src/utils/extend-schema.ts b/ts/packages/json-schema-to-zod/src/utils/extend-schema.ts
index 1fd0ed720..718568572 100644
--- a/ts/packages/json-schema-to-zod/src/utils/extend-schema.ts
+++ b/ts/packages/json-schema-to-zod/src/utils/extend-schema.ts
@@ -3,21 +3,22 @@ import type { z } from 'zod';
import type { JsonSchemaObject } from '../types';
export function extendSchemaWithMessage<
- TZod extends z.ZodTypeAny,
- TJson extends JsonSchemaObject,
- TKey extends keyof TJson,
+ TZod extends z.ZodTypeAny,
+ TJson extends JsonSchemaObject,
+ TKey extends keyof TJson,
>(
- zodSchema: TZod,
- jsonSchema: TJson,
- key: TKey,
- extend: (zodSchema: TZod, value: NonNullable<TJson[TKey]>, errorMessage?: string) => TZod,
+ zodSchema: TZod,
+ jsonSchema: TJson,
+ key: TKey,
+ extend: (zodSchema: TZod, value: NonNullable<TJson[TKey]>, errorMessage?: string) => TZod
) {
- const value = jsonSchema[key];
+ const value = jsonSchema[key];
- if (value !== undefined) {
- const errorMessage = jsonSchema.errorMessage?.[key as string];
- return extend(zodSchema, value as NonNullable<TJson[TKey]>, errorMessage);
- }
+ if (value !== undefined) {
+ const errorMessage = (jsonSchema as unknown as { errorMessage?: Record<string, string> })
+ .errorMessage?.[key as string];
+ return extend(zodSchema, value as NonNullable<TJson[TKey]>, errorMessage);
+ }
- return zodSchema;
+ return zodSchema;
}
diff --git a/ts/packages/json-schema-to-zod/test/json-to-zod.test.ts b/ts/packages/json-schema-to-zod/test/json-to-zod.test.ts
index 99aae3afa..f058e9294 100644
--- a/ts/packages/json-schema-to-zod/test/json-to-zod.test.ts
+++ b/ts/packages/json-schema-to-zod/test/json-to-zod.test.ts
@@ -123,6 +123,63 @@ describe('jsonSchemaToZod', () => {
expect(zodSchema.parse(15)).toBe(15);
expect(() => zodSchema.parse(17)).toThrow();
});
+
+ it('should handle generic min and max properties for numbers', () => {
+ const schema: JsonSchema = {
+ type: 'number',
+ min: 0,
+ max: 100,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.parse(50)).toBe(50);
+ expect(() => zodSchema.parse(-1)).toThrow();
+ expect(() => zodSchema.parse(101)).toThrow();
+ });
+
+ it('should prioritize minimum/maximum over min/max for numbers', () => {
+ const schema: JsonSchema = {
+ type: 'number',
+ minimum: 10,
+ maximum: 90,
+ min: 0,
+ max: 100,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.parse(50)).toBe(50);
+ expect(zodSchema.parse(10)).toBe(10);
+ expect(zodSchema.parse(90)).toBe(90);
+ expect(() => zodSchema.parse(5)).toThrow(); // Uses minimum (10), not min (0)
+ expect(() => zodSchema.parse(95)).toThrow(); // Uses maximum (90), not max (100)
+ });
+ });
+
+ describe('String Validations', () => {
+ it('should handle generic min and max properties for strings', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ min: 3,
+ max: 10,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.parse('hello')).toBe('hello');
+ expect(() => zodSchema.parse('hi')).toThrow();
+ expect(() => zodSchema.parse('this is too long')).toThrow();
+ });
+
+ it('should prioritize minLength/maxLength over min/max for strings', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ minLength: 5,
+ maxLength: 8,
+ min: 3,
+ max: 10,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.parse('hello')).toBe('hello');
+ expect(zodSchema.parse('testing')).toBe('testing');
+ expect(() => zodSchema.parse('test')).toThrow(); // Uses minLength (5), not min (3)
+ expect(() => zodSchema.parse('toolongstring')).toThrow(); // Uses maxLength (8), not max (10)
+ });
});
describe('Object Schemas', () => {
@@ -205,6 +262,41 @@ describe('jsonSchemaToZod', () => {
expect(() => zodSchema.parse(['one', 'two', 'three', 'four'])).toThrow();
});
+ it('should handle generic min and max properties for arrays', () => {
+ const schema: JsonSchema = {
+ type: 'array',
+ items: { type: 'string' },
+ min: 1,
+ max: 3,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.parse(['one'])).toEqual(['one']);
+ expect(zodSchema.parse(['one', 'two', 'three'])).toEqual(['one', 'two', 'three']);
+ expect(() => zodSchema.parse([])).toThrow();
+ expect(() => zodSchema.parse(['one', 'two', 'three', 'four'])).toThrow();
+ });
+
+ it('should prioritize minItems/maxItems over min/max for arrays', () => {
+ const schema: JsonSchema = {
+ type: 'array',
+ items: { type: 'string' },
+ minItems: 2,
+ maxItems: 4,
+ min: 1,
+ max: 3,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.parse(['one', 'two'])).toEqual(['one', 'two']);
+ expect(zodSchema.parse(['one', 'two', 'three', 'four'])).toEqual([
+ 'one',
+ 'two',
+ 'three',
+ 'four',
+ ]);
+ expect(() => zodSchema.parse(['one'])).toThrow(); // Uses minItems (2), not min (1)
+ expect(() => zodSchema.parse(['one', 'two', 'three', 'four', 'five'])).toThrow(); // Uses maxItems (4), not max (3)
+ });
+
it('should handle arrays with anyOf patterns', () => {
const schema: JsonSchema = {
type: 'array',
@@ -654,5 +746,115 @@ describe('jsonSchemaToZod', () => {
const shape = (zodSchema as any)._def.shape();
expect(shape.username.description).toBe('The username of the Hacker News user to retrieve.');
});
+
+ it('should append example to description', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ description: 'User name',
+ example: 'john_doe',
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('User name\nExample: "john_doe"');
+ });
+
+ it('should handle example without description', () => {
+ const schema: JsonSchema = {
+ type: 'number',
+ example: 42,
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('Example: 42');
+ });
+
+ it('should handle example with title but no description', () => {
+ const schema: JsonSchema = {
+ type: 'object',
+ title: 'User Object',
+ example: { name: 'John', age: 30 },
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('User Object\nExample: {"name":"John","age":30}');
+ });
+
+ it('should handle single example in examples array', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ description: 'Property name',
+ examples: ['lifecyclestage'],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('Property name\nExample: "lifecyclestage"');
+ });
+
+ it('should handle multiple examples in examples array', () => {
+ const schema: JsonSchema = {
+ type: 'array',
+ description: 'List of property names',
+ examples: ["['lifecyclestage', 'hs_lead_status']", "['hubspot_owner_id']"],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe(
+ "List of property names\nExamples:\n \"['lifecyclestage', 'hs_lead_status']\"\n \"['hubspot_owner_id']\""
+ );
+ });
+
+ it('should prioritize example over examples', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ description: 'Property name',
+ example: 'single_example',
+ examples: ['example1', 'example2'],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('Property name\nExample: "single_example"');
+ });
+
+ it('should handle empty examples array', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ description: 'Property name',
+ examples: [],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('Property name');
+ });
+
+ it('should preserve array structure in examples', () => {
+ const schema: JsonSchema = {
+ type: 'array',
+ description: 'Property combinations',
+ examples: [
+ ['lifecyclestage', 'hs_lead_status'],
+ ['hubspot_owner_id'],
+ ['created_date', 'modified_date', 'status'],
+ ],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe(
+ 'Property combinations\nExamples:\n ["lifecyclestage","hs_lead_status"]\n ["hubspot_owner_id"]\n ["created_date","modified_date","status"]'
+ );
+ });
+
+ it('should handle primitive types in examples array', () => {
+ const schema: JsonSchema = {
+ type: 'string',
+ description: 'Status values',
+ examples: ['active', 'inactive', 'pending'],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe(
+ 'Status values\nExamples:\n "active"\n "inactive"\n "pending"'
+ );
+ });
+
+ it('should handle mixed primitive types in examples array', () => {
+ const schema: JsonSchema = {
+ type: 'number',
+ description: 'Various numbers',
+ examples: [42, 3.14, 0, -5],
+ } as any;
+ const zodSchema = jsonSchemaToZod(schema);
+ expect(zodSchema.description).toBe('Various numbers\nExamples:\n 42\n 3.14\n 0\n -5');
+ });
});
});
diff --git a/ts/packages/providers/anthropic/CHANGELOG.md b/ts/packages/providers/anthropic/CHANGELOG.md
index 8fad057ad..c75c28465 100644
--- a/ts/packages/providers/anthropic/CHANGELOG.md
+++ b/ts/packages/providers/anthropic/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/anthropic
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/anthropic/package.json b/ts/packages/providers/anthropic/package.json
index 79c4f1c00..2db83624e 100644
--- a/ts/packages/providers/anthropic/package.json
+++ b/ts/packages/providers/anthropic/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/anthropic",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "Non-Agentic Provider for Anthropic in Composio SDK",
"main": "src/index.ts",
"type": "module",
@@ -35,7 +35,7 @@
"packageManager": "[email protected]",
"peerDependencies": {
"@anthropic-ai/sdk": "^0.52.0",
- "@composio/core": "0.1.38"
+ "@composio/core": "0.1.39"
},
"devDependencies": {
"@composio/core": "workspace:*",
diff --git a/ts/packages/providers/cloudflare/CHANGELOG.md b/ts/packages/providers/cloudflare/CHANGELOG.md
index 3d82c18c5..9cd1fa688 100644
--- a/ts/packages/providers/cloudflare/CHANGELOG.md
+++ b/ts/packages/providers/cloudflare/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/cloudflare
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/cloudflare/package.json b/ts/packages/providers/cloudflare/package.json
index 90d89e2f1..0586d34fb 100644
--- a/ts/packages/providers/cloudflare/package.json
+++ b/ts/packages/providers/cloudflare/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/cloudflare",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "",
"main": "src/index.ts",
"type": "module",
@@ -31,7 +31,7 @@
"packageManager": "[email protected]",
"peerDependencies": {
"@cloudflare/workers-types": "^4.20250416.0",
- "@composio/core": "0.1.38"
+ "@composio/core": "0.1.39"
},
"devDependencies": {
"@composio/core": "workspace:*",
diff --git a/ts/packages/providers/google/CHANGELOG.md b/ts/packages/providers/google/CHANGELOG.md
index e92563b9e..a87813588 100644
--- a/ts/packages/providers/google/CHANGELOG.md
+++ b/ts/packages/providers/google/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/google
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/google/package.json b/ts/packages/providers/google/package.json
index f8ff29fe3..5af0d325f 100644
--- a/ts/packages/providers/google/package.json
+++ b/ts/packages/providers/google/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/google",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "Google GenAI Provider for Composio SDK",
"main": "src/index.ts",
"type": "module",
@@ -36,7 +36,7 @@
"license": "ISC",
"packageManager": "[email protected]",
"peerDependencies": {
- "@composio/core": "0.1.38",
+ "@composio/core": "0.1.39",
"@google/genai": "^1.1.0"
},
"devDependencies": {
diff --git a/ts/packages/providers/langchain/CHANGELOG.md b/ts/packages/providers/langchain/CHANGELOG.md
index d31acf464..b215d38a1 100644
--- a/ts/packages/providers/langchain/CHANGELOG.md
+++ b/ts/packages/providers/langchain/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/langchain
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/langchain/package.json b/ts/packages/providers/langchain/package.json
index 618cdc9da..ac9fc0f31 100644
--- a/ts/packages/providers/langchain/package.json
+++ b/ts/packages/providers/langchain/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/langchain",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "",
"main": "dist/index.js",
"type": "module",
@@ -30,7 +30,7 @@
"license": "ISC",
"packageManager": "[email protected]",
"peerDependencies": {
- "@composio/core": "0.1.38",
+ "@composio/core": "0.1.39",
"@langchain/core": "^0.3.63"
},
"devDependencies": {
diff --git a/ts/packages/providers/mastra/CHANGELOG.md b/ts/packages/providers/mastra/CHANGELOG.md
index e878fddee..f2deac541 100644
--- a/ts/packages/providers/mastra/CHANGELOG.md
+++ b/ts/packages/providers/mastra/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/mastra
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/mastra/package.json b/ts/packages/providers/mastra/package.json
index 2368be6c4..1e57602a7 100644
--- a/ts/packages/providers/mastra/package.json
+++ b/ts/packages/providers/mastra/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/mastra",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "Agentic Provider for mastra in Composio SDK",
"main": "src/index.ts",
"type": "module",
@@ -34,7 +34,7 @@
"license": "ISC",
"packageManager": "[email protected]",
"peerDependencies": {
- "@composio/core": "0.1.38",
+ "@composio/core": "0.1.39",
"@mastra/core": "^0.10.0"
},
"devDependencies": {
diff --git a/ts/packages/providers/openai-agents/CHANGELOG.md b/ts/packages/providers/openai-agents/CHANGELOG.md
index 857f4407b..bc9553127 100644
--- a/ts/packages/providers/openai-agents/CHANGELOG.md
+++ b/ts/packages/providers/openai-agents/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/vercel
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/openai-agents/package.json b/ts/packages/providers/openai-agents/package.json
index fe49036ed..a324ccda5 100644
--- a/ts/packages/providers/openai-agents/package.json
+++ b/ts/packages/providers/openai-agents/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/openai-agents",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "",
"main": "src/index.ts",
"type": "module",
@@ -30,7 +30,7 @@
"license": "ISC",
"packageManager": "[email protected]",
"peerDependencies": {
- "@composio/core": "0.1.38",
+ "@composio/core": "0.1.39",
"@openai/agents": "^0.0.7"
},
"devDependencies": {
diff --git a/ts/packages/providers/openai/CHANGELOG.md b/ts/packages/providers/openai/CHANGELOG.md
index 31f6acc8f..70aae47df 100644
--- a/ts/packages/providers/openai/CHANGELOG.md
+++ b/ts/packages/providers/openai/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/openai
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/openai/package.json b/ts/packages/providers/openai/package.json
index d39989d55..95b28e563 100644
--- a/ts/packages/providers/openai/package.json
+++ b/ts/packages/providers/openai/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/openai",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "",
"main": "src/index.ts",
"type": "module",
@@ -30,7 +30,7 @@
"license": "ISC",
"packageManager": "[email protected]",
"peerDependencies": {
- "@composio/core": "0.1.38",
+ "@composio/core": "0.1.39",
"openai": "^4.3.8"
},
"devDependencies": {
diff --git a/ts/packages/providers/vercel/CHANGELOG.md b/ts/packages/providers/vercel/CHANGELOG.md
index 857f4407b..bc9553127 100644
--- a/ts/packages/providers/vercel/CHANGELOG.md
+++ b/ts/packages/providers/vercel/CHANGELOG.md
@@ -1,5 +1,13 @@
# @composio/vercel
+## 0.1.39
+
+### Patch Changes
+
+- Fix jsonSchema to zod parsing which used to eliminate min/max and examples proeperties
+- Updated dependencies
+ - @composio/[email protected]
+
## 0.1.38
### Patch Changes
diff --git a/ts/packages/providers/vercel/package.json b/ts/packages/providers/vercel/package.json
index b585675d7..641e61e97 100644
--- a/ts/packages/providers/vercel/package.json
+++ b/ts/packages/providers/vercel/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/vercel",
- "version": "0.1.38",
+ "version": "0.1.39",
"description": "",
"main": "src/index.ts",
"type": "module",
@@ -30,7 +30,7 @@
"license": "ISC",
"packageManager": "[email protected]",
"peerDependencies": {
- "@composio/core": "0.1.38",
+ "@composio/core": "0.1.39",
"ai": "^4.3.8"
},
"devDependencies": {