[JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort - #24863
Conversation
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>
autoXSpringPaginated for endpoints without sort
…points-without-sort
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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>
There was a problem hiding this comment.
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>
autoXSpringPaginated for endpoints without sortautoXSpringPaginated for endpoints without sort
There was a problem hiding this comment.
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
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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>
Change autoXSpringPaginated from a boolean switch into a string-enum option with three canonical values:
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.
PR checklist
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.
Summary by cubic
Changes
autoXSpringPaginatedfrom a boolean switch into a string-enum option so Spring generators can auto-detect Pageable endpoints that have onlypageandsize(nosort). Previously auto-detection required all three parameters; nowpage-sizemode is available, and the defaultnonedisables auto-detection.none,page-size-sort, andpage-size;page-size-sortmatches the oldtruebehavior.true/falsevalues still work but log a deprecation warning when explicitly set; the unset default stays silent.additionalProperties.SpringPageableScanUtilsand shared bySpringCodegen,KotlinSpringServerCodegen, andJavaCamelServerCodegen.page-sizedetection, deprecation warnings, invalid values, and setter behavior; regenerates generator docs.Written for commit 81470a1. Summary will update on new commits.