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.

-- 
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 jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/f3f6081a-3ba3-427f-86e7-4889e5ff97bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to