StefanTerdell / zod-to-json-schema

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

Add title property of JSON Schema from zod definitions #121

Closed flower-of-the-bridges closed 2 months ago

flower-of-the-bridges commented 4 months ago

Hi

I would like to generate a JSON schema like the following:

{
  "type": "object",
  "title": "My Json Schema Title",
  "required": ["someProperty"],
  "properties": {
    "someProperty": {
      "type": "string"
    },
  },
  "additionalProperties": false
}

Is there a way to achieve a JSON Schema like that using zod definitions?

If not, what could be a possible feature to add to the library?

Thanks

StefanTerdell commented 4 months ago

I could add an option for it, probably in the coming week :)

flower-of-the-bridges commented 3 months ago

@StefanTerdell great, thanks!! If you need help, I'd be happy to contribute

StefanTerdell commented 2 months ago

@flower-of-the-bridges Bit late to the party, but you can now use the "name" and "nameStrategy" = "title" to add "title" to the root schema