spring-projects / spring-projects/spring-framework

Make AbstractSmartHttpMessageConverter more extensible, allowing for custom hints

Open
#36,561 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

** Enhancements requests **
My use case would be to customize the Json Serialization process for some specific RestController method, and more specifically when serializing a list of objects I want to ignore Jackson identity information to and let Spring/Jackson serialize a small referenced object corresponding to an entity multiple times in order to allow the client to display the information more easily as a table.

I think the hints mechanism would be well suited for something more generic. As per my understanding of spring http I can see the following implementation paths,

  • AbstractJacksonHttpMessageConverter is slightly refactored to offer a method createMapper or customizeMapper that could be overridden to support handling of custom hints. Then we could provide our own converter!
  • A new general Hint CustomizeMapper or an Hint Mixins could be implemented in internalWrite/internalRead besides Views and Filters handling. The Hint when present would steer the creation of new Mapper using Jackson efficient "rebuild", customize, "build" or "rebuild", addMixins, "build" pattern.

I'd happily discuss it here and / or submit a pull request if Spring maintainers support the idea.

Thanks you all at Spring for your great work ;)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading AbstractSmartHttpMessageConverter and AbstractJacksonHttpMessageConverter, especially the internalWrite/internalRead paths that handle views and filters. Compare the proposed createMapper/customizeMapper and custom-hint approaches, then determine the supported extension point and its expected behavior for controller-specific Jackson serialization hints.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.