spring-cloud / spring-cloud/spring-cloud-openfeign

Support for spring Converter beans for @PathVariables

Open
#481 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
1.3k
Forks
838
Avg merge
2d 11h
Merged PRs (30d)
13

Description

I would like to be able to use custom value objects in my feign clients.

For example:

@FeignClient
public interface MyClient {

  @GetMapping("/users/{userId}")
  User getUser(@PathVariable UserId userId);
}

Note how the @PathVariable is typed to UserId, not to String.

I tried adding a org.springframework.core.convert.converter.Converter<UserId,String> in the application context that converts from UserId to String, but that was not used. The toString() method of UserId was still used instead.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how @PathVariable values are converted in the Spring OpenFeign integration and how application-context Converter<UserId,String> beans are discovered. Reproduce the example with a custom UserId and verify that the registered Converter is used instead of toString(); add coverage showing the expected path value.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.