Provide means to render simplified JSON representations of PageImpl
easily
#3024
Labels
Milestone
PageImpl
easily
#3024
As a follow-up to #2987 we're looking into providing a means to easily have
PageImpl
instances rendered in a simplified, stable JSON representation when returned from Spring MVC controller methods. Currently,PageImpl
is serialized as is exposing internals. The representation would also change should we ever need to change the class' API for unrelated reasons.The currently suggested better way is to rather use Spring HATEOAS
PagedModel
. While that's the best option overall, it requires an additional dependency and the user to decide for a hypermedia type to render the navigational links properly. This might not be desirable in all cases.As a middle ground, we're going to introduce a Spring Data
PagedModel
, that is a structural equivalent of the Spring HATEOAS' one but avoids adding links as navigational elements. The type can then be used in controllers explicitly (throughpage.map(PagedModel::new)
, or get applied globally by configuring@EnableSpringDataWebSupport(paginationSerializationMode = VIA_DTO)
. Not enabling that explicitly is going to cause a warning log issued that outlines the dangers of serializingPageImpl
directly and suggesting the better ways of handling the situation (either Spring Data's or Spring HATEOASPagedModel
).The text was updated successfully, but these errors were encountered: