Skip to content

sdeleuze/bean-init-modifier-with-hateaoas

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bean-init-modifier-with-hateaoas

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.

About

Sample project to demonstrate that HATEOAS ResourceSupport breaks BeanSerializerModifier functionality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 40.9%
  • Shell 34.6%
  • Batchfile 24.5%