diff --git a/docs/pom.xml b/docs/pom.xml index 25c59597..5125edd7 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -15,7 +15,7 @@ spring-cloud-openfeign ${basedir}/.. - 2.0.x + 2.0.x,2.1.x diff --git a/docs/src/main/asciidoc/sagan-boot.adoc b/docs/src/main/asciidoc/sagan-boot.adoc new file mode 100644 index 00000000..e69de29b diff --git a/docs/src/main/asciidoc/sagan-index.adoc b/docs/src/main/asciidoc/sagan-index.adoc new file mode 100644 index 00000000..b58ff33c --- /dev/null +++ b/docs/src/main/asciidoc/sagan-index.adoc @@ -0,0 +1,26 @@ +This project provides https://github.com/OpenFeign/feign[OpenFeign] integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. + +## Features + +* Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations + +## Getting Started + + +```java +@SpringBootApplication +@EnableFeignClients +public class WebApplication { + + public static void main(String[] args) { + SpringApplication.run(WebApplication.class, args); + } + + @FeignClient("name") + static interface NameService { + @RequestMapping("/") + public String getName(); + } +} + +``` diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java index af24d7ac..db2247d2 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java @@ -56,7 +56,8 @@ public final class FeignUtils { static Collection addTemplateParameter(Collection possiblyNull, String paramName) { - Collection params = ofNullable(possiblyNull).orElse(new ArrayList<>()); + Collection params = ofNullable(possiblyNull).map(ArrayList::new) + .orElse(new ArrayList<>()); params.add(String.format("{%s}", paramName)); return params; } diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java index 77bd0ede..0a79a47e 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java @@ -58,7 +58,7 @@ public class SpringDecoder implements Decoder { return extractor.extractData(new FeignResponseAdapter(response)); } - throw new DecodeException( + throw new DecodeException(response.status(), "type is not an instance of Class or ParameterizedType: " + type); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java index f6c0ffac..fabae102 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java @@ -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, @@ -653,6 +665,10 @@ public class SpringMvcContractTests { produces = MediaType.APPLICATION_JSON_VALUE) TestObject getTest(); + @GetMapping(produces = "application/json") + String testAddingTemplatedParamForExistingKey( + @RequestHeader("Accept") String accept); + } public interface TestTemplate_DateTimeFormatParameter { diff --git a/spring-cloud-openfeign-dependencies/pom.xml b/spring-cloud-openfeign-dependencies/pom.xml index 86064cce..82fa7c46 100644 --- a/spring-cloud-openfeign-dependencies/pom.xml +++ b/spring-cloud-openfeign-dependencies/pom.xml @@ -15,8 +15,8 @@ spring-cloud-openfeign-dependencies Spring Cloud OpenFeign Dependencies - 10.1.0 - 3.5.0 + 10.2.3 + 3.8.0