Allow Parametrized Types for FeignClient
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
Originally mentioned in this chat: https://gitter.im/OpenFeign/feign?at=5fc95092a8af805088fdf356
Observe:
@FeignClient(name = "queueKeeperClient", url = "${queueKeeper.api.url}", configuration = QueueKeeperFeignConfiguration.class)
public interface QueueKeeperClient<M> {
@PostMapping(path = "messages/raw/{queue}")
void publish(@PathVariable("queue") String queue,
@RequestHeader("correlationId") String correlationId,
@RequestHeader("msgId") String msgId,
@RequestBody M msgBody);
}
Throws parametrized types are not supported!
Generics is a core concept to an OOP language such as Java.
Why was this feature not considered for this when this is compile time checked and optimized?
I presume that this was done for simplicity and to force developers to avoid over engineering ...
Temporary Solution:
@FeignClient(name = "queueKeeperClient", url = "${queueKeeper.api.url}", configuration = QueueKeeperFeignConfiguration.class)
public interface QueueKeeperClient {
class QueueMessage {}
@PostMapping(path = "messages/raw/{queue}")
void publish(@PathVariable("queue") String queue,
@RequestHeader("correlationId") String correlationId,
@RequestHeader("msgId") String msgId,
@RequestBody QueueMessage msgBody);
}
Object could work too and maybe the best fit in most cases.
This is really a 'tag' class similar to Serializable.
If I have the time I would consider trying to solve this or work with someone else on this...seems like an exciting project..
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the parametrized-types error with the @FeignClient and @PostMapping example in the issue. Trace how the generic @RequestBody type is processed, then verify that a parametrized Feign client is accepted without the reported exception. Done means the example works without requiring a concrete tag class or Object workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100