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

Enum values can't be added when DataType interface has been implemented #108

Open
jerbob92 opened this issue Nov 20, 2023 · 0 comments
Open

Comments

@jerbob92
Copy link

jerbob92 commented Nov 20, 2023

We have the following setup:

  • Enums with values that are based on ints (generated with https://github.com/klippa-app/go-enum)
  • The enums values have a string representation that we use for JSON, generated/parsed by MarshalJSON and UnmarshalJSON
  • We use the DataType interface to tell OpenAPI it's actually a string and not an int
  • When you do this, an enum consisting of string values can't be added to the struct property, because the validation logic will use the original type for validation, and not the overriden type with the DataType interface.

For us there would be 2 valid solutions:

  • Make the validator aware of DataType and use that to check the enum value
  • Make another interface that returns the possible enum values for a type, this would actually make it very easy for us because then we can just add that to the go-enum generator
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