Error parsing valid JSON Schema for array types
Hi there!
First wanted to start off by saying thanks for working on such a great package, it's allowed my team to move super quickly and has been great.
Issue
Recently we noticed that some valid JSON Schema causes dezerialize to throw, specifically array item types. Here's an example:
The below is the correct JSON Schema but causes zodex to throw:
{
"type": "object",
"properties": {
"myArray": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
What works correctly for zodex, but is invalid json schema and wouldn't properly validate if the JSON Schema was used:
{
"type": "object",
"properties": {
"myArray": {
"type": "array",
"element": {
"type": "string"
}
}
}
}
I was curious if it would be possible to fix this case? Obviously for backwards compatibility element would still need to continue working but it'd be nice if zodex more closely respected the json schema spec.
Thanks in advance!
At the very least, I don't think the old way should be deprecated or removed since it more closely aligns with Zod's terminology.
I'm also not sure it would be worth the added complexity since JSON and Zodex do of course diverge.
Note, however, that there are zod-to-json-schema and json-schema-to-zod. However, note too that the latter requires use of eval. I did a little work on trying to convert the package to convert instead directly to Zodex strings, thereby circumventing the need for eval, and it may work fine, but as I recall, the fork didn't cover all possibilities: https://github.com/brettz9/json-schema-to-zod/tree/zodex .