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 for spring Converter beans for @PathVariables #481

Open
wimdeblauwe opened this issue Feb 11, 2021 · 2 comments
Open

Support for spring Converter beans for @PathVariables #481

wimdeblauwe opened this issue Feb 11, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@wimdeblauwe
Copy link

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.

@cbezmen
Copy link
Contributor

cbezmen commented May 24, 2021

You can already archive this by adding to format registrar. @wimdeblauwe

@Bean
FeignFormatterRegistrar feignFormatterRegistrar() {
	return registry -> registry.addConverter(new UserIdConverter());
}

@cbezmen
Copy link
Contributor

cbezmen commented May 26, 2021

@OlgaMaciaszek I think you can close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants