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

Optional enum fields do not correctly allow null values #1453

Open
stevenvergenz opened this issue Mar 27, 2024 · 2 comments · May be fixed by #1454
Open

Optional enum fields do not correctly allow null values #1453

stevenvergenz opened this issue Mar 27, 2024 · 2 comments · May be fixed by #1454

Comments

@stevenvergenz
Copy link

stevenvergenz commented Mar 27, 2024

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 stevenvergenz linked a pull request Mar 27, 2024 that will close this issue
@hongkongkiwi
Copy link

Seems like a solid fix! @valentinpalkovic ?

@quentin996007
Copy link

I really need this feature, please fix this issue

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

Successfully merging a pull request may close this issue.

3 participants