Skip to content

Better parameterized type serialization for the request body in RestTemplate [SPR-13154] #17745

@spring-projects-issues

Description

@spring-projects-issues

Sébastien Deleuze opened SPR-13154 and commented

Since #17408 make it possible to use parameterized type for writing the response body, it would be nice to be able to do the same for request body in client side use cases.

Since we don't have this information in the method declaration like for server side, the user will have to provide the type explicitly.

The proposal for this:

  • Retaining the type as an RequestEntity#type property
  • In RequestEntity.BodyBuilder, adding RequestEntity<T> body(T body, Type type) method
  • In RestTemplate#doWithRequest(), use RequestEntity#type if defined to get the type information, and call the type-aware canWrite() and write() methods if the message converter implements GenericHttpMessageConverter

Issue Links:

Referenced from: commits 3329abf

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions