Skip to content

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

@jerbob92

Description

@jerbob92

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions