Skip to content

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

Open
@chris-muller

Description

@chris-muller

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions