-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to specify Jackson JSON view serialization hints with @RestController and Webflux #25596
Comments
@monstrfolk you have seen JSON Views section in the docs? |
How can the JsonView be set within the controller method or dynamically at runtime? Would like to set the view dynamically based off of some other property. The 2 examples in original post support dynamically setting the JsonView. |
I see. Have you tried returning |
@rstoyanchev, thanks for you help. Could you please provide an example? |
@RestController
public class FooController {
@GetMapping("/")
MappingJacksonValue handle() {
Foo foo = new Foo();
return new MappingJacksonValue(foo);
}
} |
How can something as following be achieved? |
I don't understand what you're missing. You would do exactly as your comment says: "Return mono response entity with mapping jackson value". For example: @RestController
public class FooController {
@GetMapping("/")
Mono<ResponseEntity<MappingJacksonValue>> handle() {
Mono<Foo> fooMono = ... ;
return fooMono.map(foo -> ResponseEntity.ok(new MappingJacksonValue(foo)));
}
} |
@rstoyanchev is there a setting I need to enable to allow WebFlux w/ annotation routing recognize Here is a demo repo exemplifying the problem. |
@jnfeinstein on the WebFlux side the |
Thanks @rstoyanchev. I've opened #26035. |
There is not documentation how to filter fields using JsonViews using specific security roles when using Webflux and non-functional endpoints, for example
@RestController
.There is a tutorial that explains how to achieve this using MCV.
https://www.baeldung.com/spring-security-role-filter-json
There is another issue that has been closed that explains similar functionality with RouterFunctions and Webflux.
#23150
The text was updated successfully, but these errors were encountered: