-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Hi,
currently a wrong type is set, when using the JacksonOption.FLATTENED_ENUMS_FROM_JSONVALUE in combination with an enum to get a constant with a specific type. The type is string but the getter annotated with @JsonValue is from type Integer. I expected that the type would be from type Integer:
The Enum:
public enum VersionTwo {
VERSION_TWO(2);
private final Integer value;
VersionTwo(Integer value) {
this.value = value;
}
@JsonValue
public Integer getValue() {
return value;
}
}
Usage of Enum in Class
@NotNull
@JsonProperty(value = "VERSION")
private VersionTwo version;
The generated Json:
...
"VERSION" : {
"type" : "string",
"const" : 2
}
...
The expected generated Json:
...
"VERSION" : {
"type" : "integer",
"const" : 2
}
...
Configuration:
JacksonModule moduleJackson =
new JacksonModule(
JacksonOption.RESPECT_JSONPROPERTY_ORDER,
JacksonOption.RESPECT_JSONPROPERTY_REQUIRED,
JacksonOption.FLATTENED_ENUMS_FROM_JSONVALUE);
JakartaValidationModule moduleJavax =
new JakartaValidationModule(
JakartaValidationOption.NOT_NULLABLE_FIELD_IS_REQUIRED,
JakartaValidationOption.INCLUDE_PATTERN_EXPRESSIONS);
SchemaGeneratorConfigBuilder configBuilder =
new SchemaGeneratorConfigBuilder(
SchemaVersion.DRAFT_2019_09,
OptionPreset.PLAIN_JSON)
.with(moduleJavax)
.with(moduleJackson);
Metadata
Metadata
Assignees
Labels
No labels