Skip to content

[JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort - #24863

Draft
Picazsoo wants to merge 5 commits into
OpenAPITools:masterfrom
Picazsoo:feature/allow-autoXSpringPaginated-for-endpoints-without-sort
Draft

[JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort#24863
Picazsoo wants to merge 5 commits into
OpenAPITools:masterfrom
Picazsoo:feature/allow-autoXSpringPaginated-for-endpoints-without-sort

Conversation

@Picazsoo

@Picazsoo Picazsoo commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Change autoXSpringPaginated from a boolean switch into a string-enum option with three canonical values:

  • none: disable auto-detection (default)
  • page-size-sort: require page, size, and sort query parameters (identical to the previous true behavior)
  • page-size: require only page and size; sort may be absent (new)

The legacy true/false values are still accepted as deprecated aliases for page-size-sort/none respectively. A deprecation warning is logged once via the generator logger only when the option is explicitly set to true/false; leaving the option unset keeps the silent none default with no warning.

  • Add SpringPageableScanUtils.AutoPaginationMode enum and resolveAutoPaginationMode() to centralize parsing/validation/deprecation warnings shared by SpringCodegen and KotlinSpringServerCodegen.
  • Update willBePageable, applyAutoXSpringPaginatedIfNeeded, and the scanSortValidationEnums/scanPageableDefaults/scanPageableConstraints/ scanAll methods to take AutoPaginationMode instead of boolean.
  • Replace the boolean CLI switch with a documented string-enum CLI option in SpringCodegen and KotlinSpringServerCodegen (JavaCamelServerCodegen inherits the behavior since it extends SpringCodegen).
  • Update existing tests to use the new enum where internal signatures changed; add new tests for page-size mode detection, deprecation warnings (once when explicit, never when unset), and invalid values.
  • Regenerate docs/generators/{spring,kotlin-spring,java-camel}.md.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Changes autoXSpringPaginated from a boolean switch into a string-enum option so Spring generators can auto-detect Pageable endpoints that have only page and size (no sort). Previously auto-detection required all three parameters; now page-size mode is available, and the default none disables auto-detection.

  • Accepts canonical values none, page-size-sort, and page-size; page-size-sort matches the old true behavior.
  • Legacy true/false values still work but log a deprecation warning when explicitly set; the unset default stays silent.
  • Public string and deprecated boolean setters are preserved for both Spring and Kotlin generators; an unset Kotlin option stays out of additionalProperties.
  • Parsing, validation, and the CLI enum values are centralized in SpringPageableScanUtils and shared by SpringCodegen, KotlinSpringServerCodegen, and JavaCamelServerCodegen.
  • Adds tests for page-size detection, deprecation warnings, invalid values, and setter behavior; regenerates generator docs.

Written for commit 81470a1. Summary will update on new commits.

Review in cubic

Change autoXSpringPaginated from a boolean switch into a string-enum option
with three canonical values:

- none: disable auto-detection (default)
- page-size-sort: require page, size, and sort query parameters (identical
  to the previous true behavior)
- page-size: require only page and size; sort may be absent (new)

The legacy true/false values are still accepted as deprecated aliases for
page-size-sort/none respectively. A deprecation warning is logged once via
the generator logger only when the option is explicitly set to true/false;
leaving the option unset keeps the silent none default with no warning.

- Add SpringPageableScanUtils.AutoPaginationMode enum and
  resolveAutoPaginationMode() to centralize parsing/validation/deprecation
  warnings shared by SpringCodegen and KotlinSpringServerCodegen.
- Update willBePageable, applyAutoXSpringPaginatedIfNeeded, and the
  scanSortValidationEnums/scanPageableDefaults/scanPageableConstraints/
  scanAll methods to take AutoPaginationMode instead of boolean.
- Replace the boolean CLI switch with a documented string-enum CLI option
  in SpringCodegen and KotlinSpringServerCodegen (JavaCamelServerCodegen
  inherits the behavior since it extends SpringCodegen).
- Update existing tests to use the new enum where internal signatures
  changed; add new tests for page-size mode detection, deprecation
  warnings (once when explicit, never when unset), and invalid values.
- Regenerate docs/generators/{spring,kotlin-spring,java-camel}.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo Picazsoo changed the title [JAVA-SPRING;KOTLIN-SPRING]Allow autoXSpringPaginated for endpoints without sort [JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort Sep 4, 2026
@Picazsoo
Picazsoo marked this pull request as ready for review September 8, 2026 05:26

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Picazsoo
Picazsoo marked this pull request as draft September 8, 2026 06:05
Preserve public string and deprecated boolean setter APIs for Spring and Kotlin Spring generators. Keep Kotlin autoXSpringPaginated absent from additionalProperties when it is unset, matching Spring behavior. Replace binding-dependent logback test capture with direct setter and option-state assertions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 12:06
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 12:06

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Share the immutable auto-pagination CLI enum map from SpringPageableScanUtils so Spring and Kotlin Spring generators cannot diverge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 12:56
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 12:56
@Picazsoo Picazsoo changed the title [JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort [JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort Sep 9, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Re-trigger cubic

@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 13:16
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 13:17

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 9 files

Re-trigger cubic

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 16:24
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 16:25

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringPageableScanUtils.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringPageableScanUtils.java:151">
P3: Repeated resolution of an explicit legacy value emits a deprecation warning every time. Add once-only warning handling so repeated setter or option-processing calls do not flood logs.</violation>

<violation number="2" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringPageableScanUtils.java:310">
P2: When an operation has non-query parameters named `page` and `size`, `PAGE_SIZE` auto-detection injects `Pageable` incorrectly. Filter resolved parameters to `in: query` before checking the required names.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

.map(parameter -> resolveParameter(openAPI, parameter).getName())
.collect(Collectors.toSet());
return paramNames.containsAll(DEFAULT_PAGEABLE_QUERY_PARAMS);
return paramNames.containsAll(autoPaginationMode.getRequiredParams());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: When an operation has non-query parameters named page and size, PAGE_SIZE auto-detection injects Pageable incorrectly. Filter resolved parameters to in: query before checking the required names.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringPageableScanUtils.java, line 310:

<comment>When an operation has non-query parameters named `page` and `size`, `PAGE_SIZE` auto-detection injects `Pageable` incorrectly. Filter resolved parameters to `in: query` before checking the required names.</comment>

<file context>
@@ -176,30 +283,31 @@ public void applyPageableAnnotations(
                 .map(parameter -> resolveParameter(openAPI, parameter).getName())
                 .collect(Collectors.toSet());
-        return paramNames.containsAll(DEFAULT_PAGEABLE_QUERY_PARAMS);
+        return paramNames.containsAll(autoPaginationMode.getRequiredParams());
     }
 
</file context>

case AUTO_PAGINATION_MODE_PAGE_SIZE:
return AutoPaginationMode.PAGE_SIZE;
case AUTO_PAGINATION_MODE_LEGACY_FALSE:
deprecationWarn.accept(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: Repeated resolution of an explicit legacy value emits a deprecation warning every time. Add once-only warning handling so repeated setter or option-processing calls do not flood logs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringPageableScanUtils.java, line 151:

<comment>Repeated resolution of an explicit legacy value emits a deprecation warning every time. Add once-only warning handling so repeated setter or option-processing calls do not flood logs.</comment>

<file context>
@@ -59,6 +60,112 @@ public class SpringPageableScanUtils {
+            case AUTO_PAGINATION_MODE_PAGE_SIZE:
+                return AutoPaginationMode.PAGE_SIZE;
+            case AUTO_PAGINATION_MODE_LEGACY_FALSE:
+                deprecationWarn.accept(
+                        "autoXSpringPaginated: 'false' is deprecated and will be removed in a future release. "
+                        + "Please use '" + AUTO_PAGINATION_MODE_NONE + "' instead.");
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant