Skip to content

Fix #1324: Add @JsonAlias support to SimplePageable for SNAKE_CASE compatibility#1331

Open
weslyvinicius wants to merge 3 commits intospring-cloud:4.3.xfrom
weslyvinicius:fix-1324-page-snake-case-support-4.3.x
Open

Fix #1324: Add @JsonAlias support to SimplePageable for SNAKE_CASE compatibility#1331
weslyvinicius wants to merge 3 commits intospring-cloud:4.3.xfrom
weslyvinicius:fix-1324-page-snake-case-support-4.3.x

Conversation

@weslyvinicius
Copy link

Fixes #1324

When a global PropertyNamingStrategies.SNAKE_CASE is configured, deserialization of Page fails because SimplePageable only accepted camelCase property names.

This PR adds @JsonProperty + @JsonAlias to the constructor parameters, supporting:

pageNumber / page_number / page-number / pagenumber
pageSize / page_size / page-size / pagesize
Tested with the reproduction case provided in the issue (global SNAKE_CASE + WireMock returning snake_case JSON).

…NAKE_CASE compatibility

Signed-off-by: weslyvinicius <weslyvinicius@hotmail.com>
…NAKE_CASE compatibility

Signed-off-by: weslyvinicius <weslyvinicius@hotmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #1324 by adding @JsonAlias support to the SimplePageable class in PageJacksonModule, enabling proper deserialization of Spring Data Page objects when a global Jackson PropertyNamingStrategy (such as SNAKE_CASE) is configured. Previously, the hardcoded @JsonProperty annotations with camelCase names conflicted with global naming strategies, causing deserialization failures.

Changes:

  • Added @JsonAlias annotations to SimplePageable constructor parameters to support multiple naming conventions (snake_case, kebab-case, lowercase, PascalCase)
  • Added comprehensive test coverage with 4 new test methods and JSON fixtures for different naming strategies
  • Maintains backward compatibility by keeping camelCase as the primary @JsonProperty value

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageJacksonModule.java Added @JsonAlias annotations to SimplePageable constructor parameters for pageNumber and pageSize to support multiple naming conventions
spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageJacksonModuleTests.java Added 4 test methods to verify deserialization with different PropertyNamingStrategies (KEBAB_CASE, SNAKE_CASE, LOWER_CASE, UPPER_CAMEL_CASE)
spring-cloud-openfeign-core/src/test/resources/withPageableAliasHyphen.json Test fixture with kebab-case naming (page-number, page-size)
spring-cloud-openfeign-core/src/test/resources/withPageableAliasUnderscore.json Test fixture with snake_case naming (page_number, page_size)
spring-cloud-openfeign-core/src/test/resources/withPageableAliasLowercase.json Test fixture with lowercase naming (pagenumber, pagesize)
spring-cloud-openfeign-core/src/test/resources/withPageableAliasPascalCase.json Test fixture with PascalCase naming (PageNumber, PageSize)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: weslyvinicius <weslyvinicius@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add @JsonAlias support to SimplePageable in PageJacksonModule for snake_case compatibility with global SNAKE_CASE naming strategy

3 participants