Adds base api support via single-inheritance interfaces#246
Conversation
29191ae to
b568814
Compare
Before this change, apis that follow patterns across a service could only be modeled by copy/paste/find/replace. Especially with a large count, this is monotonous and error prone. This change introduces support for base apis via single-inheritance interfaces. Users ensure their target interface bind any type variables and as a result have little effort to create boilerplate apis. Ex. ```java @headers("Accept: application/json") interface BaseApi<V> { @RequestLine("GET /api/{key}") V get(@Param("key") String); @RequestLine("GET /api") List<V> list(); @headers("Content-Type: application/json") @RequestLine("PUT /api/{key}") void put(@Param("key") String, V value); } interface FooApi extends BaseApi<Foo> { } interface BarApi extends BaseApi<Bar> { } ``` closes #133
b568814 to
0aac921
Compare
|
NetflixOSS » feign » feign-pull-requests #129 SUCCESS |
|
This PR is sad nobody cares about it.. |
|
I like it! It would be useful for spring Cloud.
|
|
I definitely like it, and look forward to testing it out. I'm not that used to using GitHub and their PR system, so it wasn't clear to me that you were done with the work you were doing. I apologize if that caused any confusion. @spencergibb I'm using Feign via Spring Cloud. Do you have plans to pull this to a branch that I can test with, or should I just pull the feign branch itself? |
|
@zampettim As soon as a Feign release is done with the PR, we can bring it into then next version of Spring Cloud Netflix. |
|
@adriancole This would solve this SO |
Adds base api support via single-inheritance interfaces
|
8.6.0 on the way! |
|
@adriancole Any chance this could get this merged back to 7.x? |
|
@bstick12 I'll try to backport this tomorrow morning. Sorry about the delay! |
|
@bstick12 v7.6.0 on the way |
|
@adriancole Thanks very much. |
|
Can you remember if it was choice to make it only support single-inheritance or is there a fundamental reason why it couldn't or shouldn't support multilevel-inheritance? (or to put it another way: do you think it's worth my looking into making it support multilevel inheritance?) |
|
it was a decision to remove many of the edge cases: reflection, resolving
methods that exist in multiple interfaces etc.
|
|
@adriancole This code is automatically generated. This is custom code Now write a client interface The result is the wrong: "Only single inheritance supported: TestClient" |
|
Because TestApiAuto is automatically generated according to the database structure, when the database changes, it will regenerate the code, so some custom methods can not be written in it |
Adds base api support via single-inheritance interfaces
Before this change, apis that follow patterns across a service could
only be modeled by copy/paste/find/replace. Especially with a large
count, this is monotonous and error prone.
This change introduces support for base apis via single-inheritance
interfaces. Users ensure their target interface bind any type variables
and as a result have little effort to create boilerplate apis.
Ex.
closes #133