https://github.com/FasterXML/jackson-databind/issues/1609
But I prefer to know your opinion due to I think that it is really an issue.
We have to integrate with an API that its swagger api model has all the fields with UPPERCASE , like the following definition:
OutputTO:
description: ...
type: object
properties:
UPPERCASEFIELD:
type: string
description: ....
example: ...
In our case, using openapi generator plugin , the field in the class is created with the following sintax:
@JsonProperty("UPPERCASE")
private String UPPERCASE;
public InputTO UPPERCASE(String UPPERCASE) {
this.UPPERCASE = UPPERCASE;
return this;
}
public String getUPPERCASE() {
return UPPERCASE;
}
public void setUPPERCASE(String UPPERCASE) {
this.UPPERCASE = UPPERCASE;
}
The problem appears when is parsed to json due to the field is duplicated:
{"uppercase":"upperCase","CAMELCASE":"camelCase","UPPERCASE":"upperCase"}
As you can see the field UPPERCASE is duplicated.
I know that there are two possible workarounds to solve this kind of stuff:
1) Put the @JsonProperty on getter, but in that case is not possible due to we use openapi generator based on spring cloud, and its template only adds the annotation on field
2) Reduce the visibility in ObjectMapper, to only explore Fields:
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
mapper.setVisibility(PropertyAccessor.GETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.SETTER, Visibility.NONE);
But we would prefer not to use this workaround.
So... Is it possible that in Jackson really exists a bug? I prefer to explore a solution in this forum first.