Bugfix/25160

Draft
PI
2mo ago
+2053-86

Why

Fixes OpenAPITools/openapi-generator#25160.

Spring's @PageableDefault.page is always zero-based, even when request parameters are configured as one-based. Copying an OpenAPI page.default: 1 directly into that annotation selects the second page when the request omits page. Generated page-validation bounds must also match Spring's internally zero-based Pageable.

What

  • Add generatePageableDefaults (default true) to Spring and Kotlin-Spring. Setting it to false suppresses both @PageableDefault and @SortDefault, without disabling validation.
  • Add oneIndexedPageParameters (default false). When enabled, convert page defaults and effective validation bounds to zero-based values; leave size and sort unchanged. Resolve fractional/exclusive bounds against the integer page domain before conversion.
  • Warn for an ambiguous page default of 1 unless indexing is explicitly configured as either true or false. Reuse TriStateBoolean to distinguish implicit defaults from explicit configuration through options or setters.
  • Fail generation clearly for invalid one-based defaults/bounds when their corresponding annotations are enabled, rather than silently clamping values or generating invalid annotations.
  • Regenerate option documentation and reuse the Java/Kotlin sort-validation samples with an isolated one-based spec. Handwritten controllers and integration tests verify the actual generated annotations, omitted/explicit page resolution, and upper bounds.
  • Run the Kotlin integration sample in a dedicated JDK 17 test group. Other samples retain compile-only checks. Keep JUnit Platform configuration local to the tested sample and preserve it during regeneration.
  • Remove duplicate client-starter dependencies from the Spring Boot 4 POM template and regenerate the four affected sample POMs. Cover both MVC (restclient) and reactive (webclient) output.

Runtime configuration and scope

oneIndexedPageParameters describes the spec; it does not configure Spring's resolver. Applications using one-based requests must separately set spring.data.web.pageable.one-indexed-parameters=true.

Both spring-boot and spring-cloud retain annotation support. Outgoing Feign page serialization is unchanged and remains a separate follow-up; matching controller/client generation options alone do not guarantee one-based round trips.

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

Fixes OpenAPITools/openapi-generator#25160 by adding configurable one-based pagination support to the Java and Kotlin Spring generators. Specs using pages starting at 1 now produce zero-based Pageable defaults and validation bounds; existing behavior is unchanged unless oneIndexedPageParameters is enabled.

  • Adds generatePageableDefaults to control @PageableDefault and @SortDefault generation independently from validation.
  • Warns when a page default of 1 has no explicit indexing configuration and fails generation for invalid one-based defaults or bounds.
  • Converts page and size bounds through shared precise logic, skips bound resolution when constraint validation is disabled, and reports overflow with the operation context.
  • Removes the duplicate test-scoped client starter from the Spring Boot 4 POM template and regenerates affected samples.
  • Disables generated placeholder Kotlin API tests so unfinished samples no longer fail, and enables JUnit Platform in Kotlin Spring Boot templates; the Kotlin sample workflow runs its handwritten tests on JDK 17.
  • Aligns runtime indexing in the Java validation sample via spring.data.web.pageable.one-indexed-parameters=true.