Search code examples
javaspringspring-bootspring-hateoasspring-cloud-feign

Disable special character escaping in call from openfeign client (boot 2.2.4) to Spring Data Rest API (boot 1.5.9)


We have a Spring Data Rest API built on Spring-Boot 1.5.9 being called from an upgraded (spring-boot 2.2.4) OpenFeign/Hateoas client.

Since upgrading the client we are hitting database constraint exceptions in the API because of "&" chars in several Person entity fields being html escaped. For example,

44TC&R&GG 

is passed as

44TC&R&GG

Is there a way to disable this encoding?

@FeignClient(contextId = "person", name = "PERSON-DATA", configuration = {FeignClientSecurityConfiguration.class, FeignConfig.class})
public interface MyClient {

 @RequestMapping(method = RequestMethod.PUT, value = "/api/orders/{personId}")
    EntityModel<Person> updatePerson(@PathVariable("personId") String personId, Person person);

Solution

  • I was able to resolve this by setting preferred http convertor to gson which has a property to disable html escaping.

    spring.http.converters.preferred-json-mapper=gson
    
    spring.gson.disable-html-escaping=true