Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Aliases in parameter annotations on a controller interface are not evaluated [SPR-17460] #21992
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(
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.
Referenced from: commits c58da71
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: 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?