Using BeanSerializerModifier on classes extending HATEOAS ResourceSupport does not work on individual objects of the class, just on lists of objects of the class. [SPR-13608] #18186
Labels
status: duplicate
A duplicate of another issue
Abhishek Bommakanti opened SPR-13608 and commented
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.
Reference URL: https://github.com/abhishek2bommakanti/bean-init-modifier-with-hateaoas.git
The text was updated successfully, but these errors were encountered: