StefanTerdell / zod-to-json-schema

Converts Zod schemas to Json schemas
ISC License
854 stars 67 forks source link

How to validate a ReadableStream response? #119

Closed thelinuxlich closed 4 months ago

thelinuxlich commented 4 months ago

I see we have the file input case solved with latest Zod, but how can we have a ReadableStream output with a zod definition?

StefanTerdell commented 4 months ago

Well, you cant really describe a stream object with json schema, so it would have to reflect the actual content. I take it the file contains binary and you dont want to deserialize it. You can represent the binary content as a base64 string and use z.string().base64(), which is now supported.

I'm not sure I understand your problem however. Can you provide some additional context?

StefanTerdell commented 4 months ago

@thelinuxlich Ok to close?

thelinuxlich commented 4 months ago

Yeah I think it's probably something on Fastify schema validation side