Skip to content

Allow Parametrized Types for FeignClient #1356

Open
@iamgollum

Description

@iamgollum

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..

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationIssues that require updates to our documentationquestionGeneral usage or 'how-to' questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions