i found a bug: convertingan element containing an enum JSON schema works when it contains only the enum, but it fails when the enumis nested inside an object.
const test = z.enum(['h1', 'h2', 'h3', 'h4']).default('h2');
console.log(z.toJSONSchema(test));
/*
{
'$schema': 'https://json-schema.org/draft/2020-12/schema',
default: 'h2',
type: 'string',
enum: [ 'h1', 'h2', 'h3', 'h4' ]
}
*/
const test2 = z.object({
test: test,
});
console.log(z.toJSONSchema(test2));
/*
{
'$schema': 'https://json-schema.org/draft/2020-12/schema',
type: 'object',
properties: { type: { default: 'h2', type: 'string', enum: [Array] } },
required: [ 'type' ],
additionalProperties: false
}
*/
i found a bug: convertingan element containing an enum JSON schema works when it contains only the enum, but it fails when the enumis nested inside an object.
the enum data is missing