StefanTerdell / zod-to-json-schema

Converts Zod schemas to Json schemas
ISC License
917 stars 76 forks source link

How to validate a ReadableStream response? #119

Closed thelinuxlich closed 6 months ago

thelinuxlich commented 6 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 6 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 6 months ago

@thelinuxlich Ok to close?

thelinuxlich commented 6 months ago

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