Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types with default value of null don't list null as a valid type. #5

Open
chris-muller opened this issue Nov 3, 2023 · 0 comments
Open

Comments

@chris-muller
Copy link

I'm trying to use the json-schema-to-zod npm package to generate Zod schemas for these schema but there's a lot of properties listed that are marked as having a default value of null but only have "type": "string" instead of "type": ["string", "null"].

For specific examples you can look at harmonized_tariff_code and country_of_origin in create_shipments_request_body.json.

This is causing an issue with the json-schema-to-zod package since the generated Zod schema gives a type error: Argument of type 'null' is not assignable to parameter of type 'string'.

country_of_origin: z
  .string()
  .min(2)
  .max(2)
  .default(null),

It would be really helpful if the nullable properties were updated to include null in their allowed types (or if they aren't actually nullable, then remove the default values).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant