spring-projects / spring-projects/spring-data-rest

Extend integration with Spring Web for updating entities beyond the URL Encoded Form media type [DATAREST-1444]

Open
#1,803 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Behrang Saeedzadeh opened DATAREST-1444 and commented

According to Spring Data JPA: How to update a model elegantly?, when an appropriate URL Encoded Form Data payload is sent to the following action handler:

@RequestMapping(
    value = "/users/{user}", 
    method = RequestMethod.PATCH
)
public … updateUser(@ModelAttribute User user) { … }

The following steps happen:

An instance of User needs to be obtained. This basically requires a Converter from String to User to be registered with Spring MVC to convert the path segment extracted from the URI template into a User. If you're e.g. using Spring Data and enable its web support as described in its reference documentation, this will work out of the box.

  1. After the existing instance was obtained, request data will be bound to the existing object.
  2. The bound object will be handed into the method.

This works only with URL Encoded Form Data. However nowadays it is very common for REST services to consume JSON, XML, and other media types too.

It would be nice if this feature was extended so that it could work with other media types too, probably by integrating with Jaxb2RootElementHttpMessageConverter, MappingJackson2XmlHttpMessageConverter, and other converters.

For more information please see:


Reference URL: https://github.com/spring-projects/spring-boot/issues/7754

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.