jersey icon indicating copy to clipboard operation
jersey copied to clipboard

Allow nested request body inside @BeanParam

Open soberich opened this issue 7 years ago • 1 comments

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.

soberich avatar Apr 17 '18 01:04 soberich

https://github.com/jersey/jersey/issues/3678

soberich avatar Apr 17 '18 01:04 soberich