spring-cloud-openfeign
spring-cloud-openfeign copied to clipboard
@PatchMapping and @DeleteMapping insert unwanted slash when using url and specific value
Replicate problem:
Pom relevant deps:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2022.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-hc5</artifactId> <!-- Required to use PATCH over default HttpURLConnection -->
</dependency>
Config in application-local.properties
feign.url=https://subdomain.address.com/endpoint
Client:
@FeignClient(name = "test-client", url = "${feign.url}")
public interface TestClient {
@PatchMapping(value = "('{id}')")
void patchTest(@PathVariable String id, @RequestBody TestDto dto);
@DeleteMapping(value = "('{id}')")
void deleteTest(@PathVariable String id);
}
Expected behaviour is a call from client.patchTest(id, dto)
results in a call to:
https://subdomain.address.com/endpoint('id')
Measured behaviour however is a call to:
https://subdomain.address.com/endpoint/('id')
introducing an additional slash and creating a bad request for both the PATCH
and the DELETE
, GET
and POST
do not exhibit this.
Desired behaviour is no magic slash.
Hello @MarcelTon , I've just tried it and I see the same behaviour for GET
also. If you were able to replicate a different behaviour for GET
, please provide your sample. Furthermore, this is not a Spring Cloud OpenFeign specific behaviour. The uriTemplate
is being added by the feign.RequestTemplate#uri(java.lang.String, boolean)
method in OF. I see you've created an issue there and they've requested you to move it here, but I'm not sure why; Furthermor, it seems to be done by design there, as OF expects to get complete path segments from the user, i.e., if you do sth like this with OF (without the Spring Cloud OF dependency in your project even):
@RequestLine("GET ('test')")
String getTest();
you will still end up with GET https://subdomain.address.com/endpoint/('test')
being called, and we expect the same with Spring Cloud OF.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.