Repository with Spring Boot project to demonstrate that Spring HATEOAS ResourceSupport class breaks the BeanSerializerModifier functionality
I'm using BeanSerializerModifier to be able to implement application-wide functionality to ignore certain JSON rendering of objects that meet a specific condition. Everything works great except for classes that extend the HATEOAS ResourceSupport class. For these classes, the functionality works as expected only if we render Collections of objects of those classes. If we try to render individual objects directly, then the custom serializer is never called.
To demonstrate, run the Spring Boot application using
mvn spring-boot:run
Then run the following commands
curl -X GET http://localhost:8080/list
curl -X GET http://localhost:8080/list-resource
The above two URLs will return the same response. This is expected behavior.
Now run the commands below
curl -X GET http://localhost:8080/person/1
curl -X GET http://localhost:8080/person-resource/1
and
curl -X GET http://localhost:8080/person/2
curl -X GET http://localhost:8080/person-resource/2
Output of these pairs of URLs is different although if everything was working correctly, they would be the same. In the second of these URLs, the custom serializer is not called.