-
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
Implementing interface in abstract class does not expose parameter annotations #24127
Comments
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference. In particular for mentions, those can be escaped with backticks. |
I cannot reproduce this. Support for method parameter annotations on an interface added in 5.1 with #15682. Please provide a sample that demonstrates the issue. |
My repo is created exactly with that problem. If you will be in my repo (or you will download it) you will see two controllers. MobileUserController and WebUserController. Controller interface got one method.
As you can see, there is Now, going back to implemented controller. You have that method overriden in both, as AbstractController does not implement that method. In swagger you will be able to see, that WebUserController
Has body able to send, while the second controller
Would be sended through Query Params ( I would expect to Hope this helps. PS. Ignore the |
Thanks for the sample. This works as expected:
The problem you're pointing out is with how Springfox interprets those annotations. I believe this here is the same underlying issue springfox/springfox#2392. |
@rstoyanchev to be honest, the problem is that if you sent it like you did, will not apply to body itself. Values will be null. But only inside the second controller will be fine. If that works as excepted, than fine. So if you will add Ofc, that will work while sending the request. It will accept the body, as this is Post HTTP method, but will not get the body from the request inside the spring. |
My mistake, I was partly thrown off by the swagger screens. Indeed it does look like when |
I made some debug and agreed with the rstoyanchev's conjecture. |
It turns out that our support for parameter annotations in an interface (#15682) only operated on the interfaces implemented by the declaring class directly. As of 5.2.5, we take interfaces across the entire class hierarchy into account. I'll use this issue to track that generalized effort, also considering a backport to 5.1.15. |
Hello there!
The problem is with the Spring-boot-web.
Spring boot version '2.2.1.RELEASE'
The bug :
If you got interface, an abstract class and implement class, the
@RequestBody
annotation will not be taken to the implemented class.Example:
After checking the url endpoint /springTest/test you will see that it does not have body.
Those informations will go to
@RequestParam
annotation instead of@RequestBody
annotation.The url will be inheritated. Just the
@RequestBody
annotation will not.Best!
PS. It looks like somebody has RequestBody username in github, to using "@" with Annotation name will provide link to that username :(
The text was updated successfully, but these errors were encountered: