StefanTerdell / zod-to-json-schema

Converts Zod schemas to Json schemas
ISC License
886 stars 71 forks source link

Helper: how to converse file type? #101

Closed caoxing9 closed 10 months ago

caoxing9 commented 10 months ago

I have a binary file field i use z.string() to express so i get the json is that

{
  type: 'object',
  properties: { file: {type: string} },
  required: [ 'file' ],
  additionalProperties: false
}

but i expect to get with format: binary like this, what can i do for it?

{
  type: 'object',
  properties: { file: {type: string, format: binary} },
  required: [ 'file' ],
  additionalProperties: false
}
StefanTerdell commented 10 months ago

Hello! There is currently no way to tell Zod that a string contains binary, so there's nothing I can do.

However, I have opened a PR for base64 validation in Zod exactly due to this issue.

https://github.com/colinhacks/zod/pull/3047

Closing this as a duplicate of #95

caoxing9 commented 10 months ago

Hello! There is currently no way to tell Zod that a string contains binary, so there's nothing I can do.

However, I have opened a PR for base64 validation in Zod exactly due to this issue.

colinhacks/zod#3047

Closing this as a duplicate of #95

thanks for replying, looking forward...