StefanTerdell / json-schema-to-zod

ISC License
322 stars 46 forks source link

Conversion of schema results in z.any() with CLI, but a correct schema on demo site #62

Closed lexwebb closed 1 year ago

lexwebb commented 1 year ago

Hello,

I'm having an issue converting a relatively simple JSON schema using the CLI, however the same schema gets converted correctly on the demo site.

I've condensed the schema down to a minimum failing example, which you can find below:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/Bestiary",
  "definitions": {
    "Bestiary": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "required": ["name"]
    }
  }
}

This results in an output of export const schema = z.any();

It's quite possible that i'm missing something, but using simple object based schemas that don't use $ref and definitions seems to work fine on the CLI.

StefanTerdell commented 1 year ago

Use -d