When a schema (for example, response schema) contains cycles, zod toJSONSchema creates _shared with refs definitions, however, in fastify-type-provider-zod@6.0.0 this attribute is ignored. And I'm getting invalid schema because it contains references to missing schemas.
To reproduce it, just add z.json() to your schema.
The place in the code where it is ignored is zod-to-json.ts when you call method zodSchemaToJson.
const {
schemas: { [tempID]: result },
} = toJSONSchema(tempRegistry, {
target,
metadata: registry,
io,
unrepresentable: 'any',
cycles: 'ref',
...
should be something like:
const {
schemas: {
[tempID]: result,
__shared,
},
} = toJSONSchema(tempRegistry, {
target,
metadata: registry,
io,
unrepresentable: 'any',
cycles: 'ref',
...
When a schema (for example, response schema) contains cycles, zod
toJSONSchemacreates_sharedwith refs definitions, however, infastify-type-provider-zod@6.0.0this attribute is ignored. And I'm getting invalid schema because it contains references to missing schemas.To reproduce it, just add
z.json()to your schema.The place in the code where it is ignored is
zod-to-json.tswhen you call methodzodSchemaToJson.should be something like: