Skip to content

fix: use Zod 4 native toJSONSchema for schema conversion#56

Merged
jpr5 merged 1 commit into
mainfrom
fix/zod4-json-schema
May 15, 2026
Merged

fix: use Zod 4 native toJSONSchema for schema conversion#56
jpr5 merged 1 commit into
mainfrom
fix/zod4-json-schema

Conversation

@jpr5
Copy link
Copy Markdown
Contributor

@jpr5 jpr5 commented May 15, 2026

Dependabot bumped zod from 3.25.76 to 4.4.3 (#37). The zod-to-json-schema library returns empty schemas with Zod 4, causing 2 test failures on main:

  • standard-schema.test.ts - standardSchemaToFormSchema returns empty fields
  • infer-from-config.test.ts - inferFormSchemaFromConfig returns empty fields for Zod schemas

Zod 4 exposes a native toJSONSchema() method on schema objects. This PR uses that when available, falling back to zod-to-json-schema for Zod 3 compatibility.

All 311 tests pass locally.

zod-to-json-schema returns empty schemas with Zod 4.x, causing
standardSchemaToFormSchema and inferFormSchemaFromConfig tests to
fail. Zod 4 exposes toJSONSchema() on schema objects; prefer that
when available, falling back to zod-to-json-schema for Zod 3.
@jpr5 jpr5 merged commit 80457a9 into main May 15, 2026
4 checks passed
@jpr5 jpr5 deleted the fix/zod4-json-schema branch May 15, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant