-
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
Aliases in parameter annotations on a controller interface are not evaluated [SPR-17460] #21992
Comments
Juergen Hoeller commented We aimed to address this in 5.1 through #15682... Could you please double-check that your case indeed does not work against 5.1.2 and ideally provide a particular case to reproduce? |
Bogdan Zafirov commented Juergen Hoeller I attached an example Spring-Boot application (created with https://start.spring.io). There is one interface (TestInterface.java) and an implementing class annotated with RestController (TestController.java). When I do a HTTP GET with the following URL http://localhost:8080/v1/test/ZZ95711905000000500000 I get 'Internal Server Error'. The error message is: "Missing URI template variable 'testId' for method parameter of type String". This actually shows that Spring is considering the variable name instead of the value set in the PathVariable (e.g. test-id) annotation. The same thing happens for the header parameter 'X-Request-ID', namely the header parameter has to named xRequestID. |
Juergen Hoeller commented Brian Clozel, could you please try to debug the repro app and double-check why this still doesn't work against 5.1.x there? |
WiedemannA commented Juergen Hoeller: I've got the same problem in version 5.1 and debugged the code: And the swagger-codegen (OpenApiGenerator likewise) generates interfaces in which only The PathVariableMethodArgumentResolver only takes over the Bogdan Zafirov: Can you verifiy, that the Problem doesn't occure, if you set both value and name? |
Juergen Hoeller commented WiedemannA, good catch! I was able to reproduce this; we indeed miss a |
Bogdan Zafirov opened SPR-17460 and commented
The problem is explained in this Stack Overflow answer: https://stackoverflow.com/a/8005644. As pointed out in the comment to this answer, this is "problem" is already solved in other frameworks such as Jersey.
The goal would be Spring Framework to consider/evaluate the annotations on interface methods (e.g. public void getUser(
@RequestParam
("user-id")), so a developer doesn't have to define the annotations in the implementing class again.By generating a server implementation from a OAS3 contract (e.g. https://github.com/OpenAPITools/openapi-generator) one can easily face this problem, since the annotations from the generated code (a Java Interface) will not be evaluated on a HTTP call.
Affects: 5.1.2
Attachments:
Issue Links:
Referenced from: commits c58da71
The text was updated successfully, but these errors were encountered: