citrusframework / citrusframework/citrus
Add support of path parameters in HttpClient in citrus-http endpoint
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**User story**
As a HTTP backend tester, I want to be able to pass path parameters when calling restful api's instead of concatenating strings to build the URI.
**Additional context**
usually path parameters are specified with curly braces, and the name doesn't really matter, but the order does and these are mandatory otherwise the uri changes.
these parameters could be specified like in the following snippet
```java
@CitrusTest
public void apiTest(@CitrusResource TestRunner runner, @CitrusResource TestContext testContext) {
// ...
testRunner.http(httpActionBuilder -> httpActionBuilder.client(httpClient)
.send()
.get("/me/{user}/bicycles/{bicycleId}")
.pathParam("user", "johndoe")
.pathParam("bicycleId", "${bikeID}")
.header(Headers.SOME_HEADER_NAME, "${aVariable}")
);
testRunner.http(httpActionBuilder -> httpActionBuilder.client(httpClient)
.receive()
.response(HttpStatus.OK)
.validate("$.someField", equalTo(expectedResult))
);
// ...
}
```
behind the scenes it seems it would require changes on
* `HttpClientRequestActionBuilder`
* `HttpMessage`
* `HttpClient` - will need to call RestTemplate exchange signature that supports path [parameters](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html#exchange-java.lang.String-org.springframework.http.HttpMethod-org.springframework.http.HttpEntity-java.lang.Class-java.lang.Object...-)
Contributor guide
Research direction
Start with HttpClientRequestActionBuilder and HttpMessage to trace how the path and request parameters are represented, then inspect HttpClient's use of the RestTemplate exchange signature that accepts path parameters. Done means the shown get() calls accept named pathParam values, including Citrus variables, and the resulting request uses them in the URI.
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