diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java index ad87d300..746cec5c 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java @@ -299,11 +299,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource } } - if (! - - isMultipartFormData(data) && isHttpAnnotation && data.indexToExpander(). - - get(paramIndex) == null) { + if (!isMultipartFormData(data) && isHttpAnnotation && data.indexToExpander().get(paramIndex) == null) { TypeDescriptor typeDescriptor = createTypeDescriptor(method, paramIndex); if (conversionService.canConvert(typeDescriptor, STRING_TYPE_DESCRIPTOR)) { Param.Expander expander = convertingExpanderFactory.getExpander(typeDescriptor); 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 fc080ed5..e43983d4 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 @@ -631,20 +631,20 @@ class SpringMvcContractTests { void shouldNotFailWhenBothPageableAndRequestBodyParamsInPostRequest() { List data = contract.parseAndValidateMetadata(TestTemplate_PageablePost.class); - assertThat(data.get(2).queryMapIndex()).isEqualTo(1); - assertThat(data.get(2).bodyIndex()).isEqualTo(0); - assertThat(data.get(3).queryMapIndex()).isEqualTo(0); - assertThat(data.get(3).bodyIndex()).isEqualTo(1); + assertThat(data.get(0).queryMapIndex()).isEqualTo(0); + assertThat(data.get(0).bodyIndex()).isEqualTo(1); + assertThat(data.get(1).queryMapIndex()).isEqualTo(1); + assertThat(data.get(1).bodyIndex()).isEqualTo(0); } @Test void shouldSetPageableAsBodyWhenQueryMapParamPresent() { - List data = contract.parseAndValidateMetadata(TestTemplate_PageablePost.class); + List data = contract.parseAndValidateMetadata(TestTemplate_PageablePostWithQueryMap.class); - assertThat(data.get(0).queryMapIndex()).isEqualTo(1); - assertThat(data.get(0).bodyIndex()).isEqualTo(0); - assertThat(data.get(1).queryMapIndex()).isEqualTo(0); - assertThat(data.get(1).bodyIndex()).isEqualTo(1); + assertThat(data.get(0).queryMapIndex()).isEqualTo(0); + assertThat(data.get(0).bodyIndex()).isEqualTo(1); + assertThat(data.get(1).queryMapIndex()).isEqualTo(1); + assertThat(data.get(1).bodyIndex()).isEqualTo(0); } private ConversionService getConversionService() { @@ -848,7 +848,7 @@ class SpringMvcContractTests { } - public interface TestTemplate_PageablePost { + interface TestTemplate_PageablePost { @PostMapping Page getPage(Pageable pageable, @RequestBody String body); @@ -856,6 +856,10 @@ class SpringMvcContractTests { @PostMapping Page getPage(@RequestBody String body, Pageable pageable); + } + + interface TestTemplate_PageablePostWithQueryMap { + @PostMapping Page getPage(@SpringQueryMap TestObject pojo, Pageable pageable);