zod-to-json-schema icon indicating copy to clipboard operation
zod-to-json-schema copied to clipboard

How to validate a ReadableStream response?

Open thelinuxlich opened this issue 9 months ago • 1 comments

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

thelinuxlich avatar Apr 30 '24 18:04 thelinuxlich

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 avatar May 02 '24 12:05 StefanTerdell

@thelinuxlich Ok to close?

StefanTerdell avatar May 06 '24 17:05 StefanTerdell

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

thelinuxlich avatar May 06 '24 17:05 thelinuxlich