On Thu, May 9, 2019 at 4:16 PM Manuel Garcia <[email protected]> wrote:
>
> HI All,
>
> We have a problem with UPPERCASE fields, like in this closed issued in Jackson
>
> 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
>
> https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache
>
> 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.
I think you may want to try enabling
MapperFeature.USE_STD_BEAN_NAMING
which I think might solve this particular problem.
-+ Tatu +-
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/CAL4a10j5gtwxog_fQVRMXAFxiSCWWe2-NX-EXZwNYws0GjqhSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.