You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My team has a coding standard of making fields public on POJOs to reduce boilerplate code. For example:
public String name;
rather than:
private String name;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
However, sometimes the POJO implements an interface that exposes the property, e.g.:
public interface HasName {
String getName);
}
In that case the POJO ends up with a public field, as well as a getter for that field, i.e.:
public String name;
public String getName() { return name; }
Jackson 2, which we use for serialization, has no issues with this. It is smart enough to serialize to a single JSON property named "name" and deserialize that property back to the "name" field.
However, Enunciate chokes on it with this error:
[ENUNCIATE] Jackson naming conflicts have been found:
[ENUNCIATE] com.example.MyPojo: accessor "getName()" conflicts with accessor "name": both are named "name".
The text was updated successfully, but these errors were encountered:
+1. I use now Spring Hateoas and I cannot annotate classes (e.g. PagedResources)
Eventually , you can add some options to the jackson module configuration, something like field="visible" method="none"
I started looking at this in more detail, but I'm afraid I'm having a hard time reproducing the issue. I've tried to set up a project with beans with public fields and public associated getters, but Enunciate handles all the cases I've been able to come up with.
Any way you could put together a sample project that exposes the issue for me?
My team has a coding standard of making fields public on POJOs to reduce boilerplate code. For example:
rather than:
However, sometimes the POJO implements an interface that exposes the property, e.g.:
In that case the POJO ends up with a public field, as well as a getter for that field, i.e.:
Jackson 2, which we use for serialization, has no issues with this. It is smart enough to serialize to a single JSON property named "name" and deserialize that property back to the "name" field.
However, Enunciate chokes on it with this error:
The text was updated successfully, but these errors were encountered: