-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow custom names to be supplied when creating an enum #385
Comments
Ah, there's no feature that allows you to specify custom names for your
|
Ah thanks! Do you think that a custom type would work in this case? |
It's just about possible (custom type, plus custom Jackson serializer) but I'd suggest just using 1, 2, 3. You'll get underscores added as a prefix to
|
Well, imagine a status flag where in the database it's represented as 1,2,3,4 but in the app it's ACTIVE/PENDING/CANCELLED/REMOVED. That's really all i'm trying to make happen. The custom type + custom jackson serializer seems like it may be too complicated to be good. I'll try to think of something else. Thanks! |
I guess ideally you'd like some way of annotating the enum values to dictate the Java names. Since the values sit alone in a plain array, there's no real opportunity to add additional metadata. I guess we could have something alongside the enum values like: {
"type" : "integer",
"enum" : [1, 2, 3, 4],
"javaEnumNames" : ["ACTIVE", "PENDING", "CANCELLED", "REMOVED"]
} |
Yeah something like that would be awesome. I think then mybatis/jackson would "just work" |
Howdy,
Having a heck of a time figuring out how to use enums as i'd like:
The examples show:
"myEnum" : {
"type" : "string",
"enum" : ["one", "secondOne", "3rd one"]
}
but what I really want is
myEnum = {
ONE (1),
TWO (2),
THREE (3)
}
Thanks
The text was updated successfully, but these errors were encountered: