Skip to content

Conversation

chenzewang
Copy link

Fixes #11: jsonSchemaObjectToZodRawShape now correctly handles the required field from JSON Schema, making only non-required properties optional.

  • Required fields remain as their base Zod types (ZodString, ZodNumber, etc.)
  • Non-required fields are wrapped with .optional()
  • When no required array is present, all fields are optional by default
  • Updated tests to reflect correct behavior

#11

Fixes glideapps#11: jsonSchemaObjectToZodRawShape now correctly handles the required
field from JSON Schema, making only non-required properties optional.

- Required fields remain as their base Zod types (ZodString, ZodNumber, etc.)
- Non-required fields are wrapped with .optional()
- When no required array is present, all fields are optional by default
- Updated tests to reflect correct behavior
@schani
Copy link
Member

schani commented Sep 12, 2025

Fantastic, thank you so much!

I'll make a 0.1.0 release in short order that incorporates this fix.

@schani schani merged commit 2bb6ef2 into glideapps:zod3 Sep 12, 2025
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.

2 participants