prisma-json-schema-generator icon indicating copy to clipboard operation
prisma-json-schema-generator copied to clipboard

Optional enum fields do not correctly allow null values

Open stevenvergenz opened this issue 10 months ago • 1 comments

enum MyEnum{
  A
  B
  C
  D
}
model MyModel {
  enumValue MyEnum?
}

This becomes:

"enumValue": {
  "type": [
      "string",
      "null"
  ],
  "enum": [
      "A",
      "B",
      "C",
      "D"
  ]
}

The type allows a null value, but the enum does not, so { "enumValue": null } does not validate. The correct solution is to include null in the list of enum values here.

stevenvergenz avatar Mar 27 '24 04:03 stevenvergenz

Seems like a solid fix! @valentinpalkovic ?

hongkongkiwi avatar Apr 12 '24 16:04 hongkongkiwi