eclipse-ee4j / eclipse-ee4j/jersey

Allow nested request body inside @BeanParam

Open
#3,806 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

That would be a brilliant aggregate
```
@Value
@Builder(toBuilder = true)
@NoArgsConstructor(force = true)
@AllArgsConstructor
public class Changes {

@Context
Locale locale;

@HeaderParam("Authorization")
String token;

@QueryParam("rewrite")
String rewrite;

@PathParam("id")
String id;

@JsonProperty
@NotNull
@Valid
AddressDTO three;

}
```
Now AddressDTO is null, of course

so instead,
```
@POST
UserDTO dostuff(@BeanParam Changes changes, @NotNull @Valid UserDTO)
```
you could just
```
@POST
UserDTO dostuff(@BeanParam Changes changes)
```
and of course deep nesting would allow even more.
Especially with some libraries like mapstruct, where all that hierarchy automatically would be remapped to any other bunch of objects with possibly completely different topology. This would allow very convenient transitioning from web-specific layer data to , say, db/persistence layer.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how @BeanParam currently binds fields and how the nested AddressDTO in the example is treated. Define the behavior for nested request-body binding, including deep nesting, and verify that the example can be represented through a single @BeanParam Changes argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.