Fix handling adding multiple parametrs for key. Fixes gh-171. (#172)
This commit is contained in:
committed by
GitHub
parent
e04056be09
commit
35ec2913d9
@@ -56,7 +56,8 @@ public final class FeignUtils {
|
||||
|
||||
static Collection<String> addTemplateParameter(Collection<String> possiblyNull,
|
||||
String paramName) {
|
||||
Collection<String> params = ofNullable(possiblyNull).orElse(new ArrayList<>());
|
||||
Collection<String> params = ofNullable(possiblyNull).map(ArrayList::new)
|
||||
.orElse(new ArrayList<>());
|
||||
params.add(String.format("{%s}", paramName));
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -523,6 +523,18 @@ public class SpringMvcContractTests {
|
||||
this.contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingTemplatedParameterWithTheSameKey()
|
||||
throws NoSuchMethodException {
|
||||
Method method = TestTemplate_Advanced.class.getDeclaredMethod(
|
||||
"testAddingTemplatedParamForExistingKey", String.class);
|
||||
MethodMetadata data = contract
|
||||
.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||
|
||||
assertThat(data.template().headers().get("Accept")).contains("application/json",
|
||||
"{Accept}");
|
||||
}
|
||||
|
||||
public interface TestTemplate_Simple {
|
||||
|
||||
@RequestMapping(value = "/test/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -645,6 +657,10 @@ public class SpringMvcContractTests {
|
||||
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
TestObject getTest();
|
||||
|
||||
@GetMapping(produces = "application/json")
|
||||
String testAddingTemplatedParamForExistingKey(
|
||||
@RequestHeader("Accept") String accept);
|
||||
|
||||
}
|
||||
|
||||
public interface TestTemplate_DateTimeFormatParameter {
|
||||
|
||||
Reference in New Issue
Block a user