StefanTerdell / zod-to-json-schema

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

feat: Add dict to nativeEnum type #105

Closed hufftheweevil closed 3 months ago

hufftheweevil commented 8 months ago

Great simple library!

Any interest in adding a dict property to nativeEnum types?

hufftheweevil commented 6 months ago

Any suggestions for a more descriptive prop? dictionary lookup lookupMap?

StefanTerdell commented 6 months ago

enumMap perhaps?

I was thinking though, maybe it's enough to just include the keys? Like

return {
  ...
  enum: ...,
  enumKeys: actualKeys
}

They should be in the same order making it possible to construct it on the other end.

Object.fromEntries(schema.enum((value, index) => [schema.enumKeys[index], value]))