Closed rorueda closed 1 month ago
Unfortunately, it is not possible to determine 100% whether a parameter is part of the request body or added using other tools. You can test this by changing your endpoint to this:
@Post
HttpResponse<SimpleBody> save(@Body SimpleBody body, Integer test, String id, FilterProvidedArgument filterProvidedArgument) {
...
And try to send request:
{
"value": "PERS",
"test": 12,
"id": "sdsdsdsd"
}
You will see that all parameters of the request body are substituted into the required method parameters:
Therefore, the only way to skip such parameters is to add the @Parameter(hidden = true)
annotation
@Post
HttpResponse<SimpleBody> save(@Body SimpleBody body, @Parameter(hidden = true) FilterProvidedArgument filterProvidedArgument) {
return HttpResponse.ok(body);
}
Thanks, @altro3.
I've opened this only because I wasn't expecting this to be the behavior of micronaut-core. I guess this behavior won't ever be changed, so I'm closing it.
Feature description
I expect a method argument annotated with
@Body
to take precedence over other non-annotated arguments.I'm creating this as a feature request because it's not that important and the workaround is trivial.