Skip to content

Fix #1324: Add @JsonAlias support to SimplePageable for SNAKE_CASE co…#1325

Closed
weslyvinicius wants to merge 2 commits intospring-cloud:mainfrom
weslyvinicius:fix-1324-page-snake-case-support
Closed

Fix #1324: Add @JsonAlias support to SimplePageable for SNAKE_CASE co…#1325
weslyvinicius wants to merge 2 commits intospring-cloud:mainfrom
weslyvinicius:fix-1324-page-snake-case-support

Conversation

@weslyvinicius
Copy link

Fixes #1324

When a global PropertyNamingStrategies.SNAKE_CASE is configured, deserialization of Page<T> 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).

Copy link
Member

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

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

Please add a test that verifies the fix.

@weslyvinicius
Copy link
Author

Thanks for the review! I've added tests to verify the fix.

The tests follow the same pattern as the existing ones in PageJacksonModuleTests:

Test methods added:

  • deserializePageableWithHyphenatedAlias() - validates page-number and page-size
  • deserializePageableWithUnderscoreAlias() - validates page_number and page_size
  • deserializePageableWithLowercaseAlias() - validates pagenumber and pagesize
  • deserializePageableWithPascalCaseAlias() - validates PageNumber and PageSize

Test resource files added (in src/test/resources/):

  • withPageableAliasHyphen.json
  • withPageableAliasUnderscore.json
  • withPageableAliasLowercase.json
  • withPageableAliasPascalCase.json

All tests pass and verify that the @JsonAlias annotations correctly handle different naming conventions for pageNumber and pageSize fields in the pageable object.

@ryanjbaxter
Copy link
Contributor

Please sign your commits so the DCO passes

@ryanjbaxter
Copy link
Contributor

Is this also a problem in the 4.3.x branch? If so please make the PR against that branch

…NAKE_CASE compatibility

Signed-off-by: weslyvinicius <weslyvinicius@hotmail.com>
Signed-off-by: weslyvinicius <weslyvinicius@hotmail.com>
@weslyvinicius weslyvinicius force-pushed the fix-1324-page-snake-case-support branch from 15c9f5b to 4e026b2 Compare February 19, 2026 21:35
@weslyvinicius
Copy link
Author

Please sign your commits so the DCO passes

Hi @ryanjbaxter,

Thanks for the heads-up!

I've fixed the DCO issue. I added the Signed-off-by line to the two commits that were missing it:

@ryanjbaxter
Copy link
Contributor

See #1325 (comment)

@weslyvinicius
Copy link
Author

Is this also a problem in the 4.3.x branch? If so please make the PR against that branch

Yes, the issue is also present in the 4.3.x branch.
I have created a separate PR targeting 4.3.x:

@spencergibb
Copy link
Member

Closing in favor of #1329. We will merge forward to main.

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

4 participants