如何更改feign客户端请求体中的字段名称?
我有一个假客户端,它使用 dto 使用 @RequestBody 执行请求。问题是某些属性与java标准不匹配,例如id_client。有没有办法更改变量名称并使其与 feign 一起工作?
下面是请求正文中使用的 dto 的 feign 客户端的代码。
@FeignClient(name="sso-token", url = "http://keycloak.com.br:8180", path="/")
public interface SsoTokenQueryWebAdapter {
@PostMapping(value = "/auth/realms/real-refrigerantes/protocol/openid-connect/token", consumes = "application/x-www-form-urlencoded")
public String recuperarToken(@RequestBody RequestTokenDto dto);
}
@Data
public class RequestTokenDto {
private String username;
private String password;
private String client_id;
private String client_secret;
private String grant_type;
}
I have a feign client that uses a dto to perform the request using @RequestBody. The problem is that some property does not match with the java standards, for example id_client. Is there a way to change the variable name and keep it working with the feign ?
Below there is the code of the feign client the dto used in the request body.
@FeignClient(name="sso-token", url = "http://keycloak.com.br:8180", path="/")
public interface SsoTokenQueryWebAdapter {
@PostMapping(value = "/auth/realms/real-refrigerantes/protocol/openid-connect/token", consumes = "application/x-www-form-urlencoded")
public String recuperarToken(@RequestBody RequestTokenDto dto);
}
@Data
public class RequestTokenDto {
private String username;
private String password;
private String client_id;
private String client_secret;
private String grant_type;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)