Skip to content
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

Support JEP 118 parameters #1297

Closed
krzyk opened this issue Oct 29, 2020 · 3 comments · Fixed by #1309
Closed

Support JEP 118 parameters #1297

krzyk opened this issue Oct 29, 2020 · 3 comments · Fixed by #1309
Labels
enhancement For recommending new capabilities feedback provided Feedback has been provided to the author

Comments

@krzyk
Copy link
Contributor

krzyk commented Oct 29, 2020

I haven't seen this issue, but it is quite hard to search for this so sorry for duplicate.

Java 8 introduced an additional javac option in (JEP 118) using -parameters to allow retrieval of parameter names during runtime.

This retrieval is supported in e.g. Spring and Jackson to reduce amount of duplication, so I think it would be good to have it in feign also.

E.g. I have following method in interface:

    @Body("{content}")
    @Headers(value = {"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /prop/{property}/ver?cont={contact}&addr={address}")
    String createNewVersion(@Param("property") String property, @Param("contact") String contact, @Param("address") String address, @Param("content") Map<String, Integer> content);

As you see the same name is both in the parameter name as well as in annotation, if -parameters would be supported this could be simplified to:

    @Body("{content}")
    @Headers(value = {"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /prop/{property}/ver?cont={contact}&addr={address}")
    String createNewVersion(@Param String property, @Param String contact, @Param String address, Map<String, Integer> content);

Currently (in 9.7.0) it is not supported because value in @Param annotation is required.

@krzyk
Copy link
Contributor Author

krzyk commented Nov 5, 2020

If you think this is a good addition to feign I could work on it.

@velo
Copy link
Member

velo commented Nov 5, 2020

If you think this is a good addition to feign I could work on it.

Awesome, that would be most appreciated!

krzyk added a commit to krzyk/feign that referenced this issue Nov 12, 2020
JEP 118 introduced javac option `-parameters` that adds to bytecode
method parameter names, so if code is compiled with that option
and @param value is empty we can get that template parameter name
from method parameter name.

Fixes OpenFeign#1297.
krzyk added a commit to krzyk/feign that referenced this issue Nov 13, 2020
JEP 118 introduced javac option `-parameters` that adds to bytecode
method parameter names, so if code is compiled with that option
and @param value is empty we can get that template parameter name
from method parameter name.

Fixes OpenFeign#1297.
krzyk added a commit to krzyk/feign that referenced this issue Nov 13, 2020
JEP 118 introduced javac option `-parameters` that adds to bytecode
method parameter names, so if code is compiled with that option
and @param value is empty we can get that template parameter name
from method parameter name.

Fixes OpenFeign#1297.
@kdavisk6 kdavisk6 added enhancement For recommending new capabilities feedback provided Feedback has been provided to the author labels Nov 17, 2020
@krzyk
Copy link
Contributor Author

krzyk commented Nov 19, 2020

@velo I've created PR #1309 for this.

krzyk added a commit to krzyk/feign that referenced this issue Nov 24, 2020
JEP 118 introduced javac option `-parameters` that adds to bytecode
method parameter names, so if code is compiled with that option
and @param value is empty we can get that template parameter name
from method parameter name.

Fixes OpenFeign#1297.
kdavisk6 pushed a commit that referenced this issue Dec 21, 2020
…#1309)

JEP 118 introduced javac option `-parameters` that adds to bytecode
method parameter names, so if code is compiled with that option
and @param value is empty we can get that template parameter name
from method parameter name.

Fixes #1297.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For recommending new capabilities feedback provided Feedback has been provided to the author
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants