spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
914 stars 560 forks source link

Make PersistentEntityJackson2Module extendable [DATAREST-1095] #1460

Open spring-projects-issues opened 7 years ago

spring-projects-issues commented 7 years ago

Valentin Rentschler opened DATAREST-1095 and commented

I'm opening this issue to ask if the project leads would agree with making the PersistentEntityJackson2Module extendable, i.e. making inner-classes public and non-static and also open for extension. I can provide a PR.

The PersistentEntityJackson2Module is very central to Spring Data Rest. It's possible to return a custom module already by returning it from the persistentEntityJackson2Module() method in RepositoryRestMvcConfiguration. But it's almost not customizable as it is


No further details from DATAREST-1095

spring-projects-issues commented 7 years ago

Oliver Drotbohm commented

The reason it's not publicly available is that it is not designed to be extended. Not meaning, we strictly don't want anyone to extend but the design being as simple as we didn't have to care about extensibility. That aspect would have been to be considered first, which we just didn't do as Spring Data REST is the only code currently using it, and you can't really design for requirements you don't know.

The other aspect ist that the implementation is very core to the way we structure responses, decide where to put links etc. So changing things here might cause ripple effects into other parts of the system as they expect certain things to render in a certain way.

Would you mind elaborating what exactly you're trying to tweak? Usually the standard Jackson extension mechanisms allow enough customization of user defined types

spring-projects-issues commented 7 years ago

Valentin Rentschler commented

I agree, making it extendable 'as is' may be dangerous. Let me iterate a few features that I have thought of or implemented already that do not necessarily fit into the concept of SDR, but which are useful in a specific use case and would be easy to implement: