-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Hey, thanks for the great lib with good extension points!
I am having the following enum class:
public static enum Day {
@JsonProperty("1")
DAY_1,
@JsonProperty("2")
DAY_2,
...
END;
}So, not all enum members have @JsonProperty annotations and in this case it seems to be natural, because it's not possible to define enum member called 1, but it does not make much sense to put @JsonProperty("END") for END.
Then I use JacksonModule to generate a schema. If I had @JsonProperty annotation on END as well, then the schema would have been generated as follows:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"r": {
"type": "string",
"enum": [
"1",
"2",
"END"
]
}
},
"required": [
"r"
]
}And this is fine. But if END does not have annotation, then the generated schema is:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"r": {
"type": "string",
"enum": [
"DAY_1",
"DAY_2",
"END"
]
}
},
"required": [
"r"
]
}However, I would expect 1 and 2 instead of DAY_1 and DAY_2.
Looks like this is intended, see CustomEnumDefinitionProvider.getSerializedValuesFromJsonProperty(), which says explicitly that even at least one enum member does not have @JsonProperty annotation, then annotations on all other members are ignored.
In my case, I cannot modify the class, so in my case the only workaround is to add a custom module. But I am still wondering, why this case is not covered by JacksonModule.