[KOTLIN;SPRING] - add support for 'x-spring-paginated' to get closer to feature parity with java-spring codegen; add 'autoXSpringPaginated' option; support x-operation-extra-annotation#22958
Merged
wing328 merged 25 commits intoOpenAPITools:masterfrom Feb 13, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
4 issues found across 63 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache:100">
P2: The Pageable parameter is added with `@Parameter(hidden = true)` but no `@ParameterObject` or explicit pagination parameters are added, so enabling x-spring-paginated will hide pagination params from generated OpenAPI docs. Springdoc expects `@ParameterObject` (or explicit query params) to expose page/size/sort; hiding the pageable without those means pagination won’t appear in the docs.</violation>
</file>
<file name="samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt">
<violation number="1" location="samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt:241">
P2: The handler declares a required @PathVariable("categoryId") but the mapped path is "/pet/paginated/mixed" without a {categoryId} placeholder, so Spring cannot bind the path variable and requests will fail.</violation>
<violation number="2" location="samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt:449">
P2: `listPetsByIdPaginated` declares a required `@PathVariable("petId")`, but the mapped path constant `/pet/paginated/pathOnly` has no `{petId}` template. Spring will fail to resolve the path variable at runtime; update the path to include `{petId}` or remove the parameter.</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache:35">
P2: Reactive builds can still generate Pageable parameters, but spring-data-commons is only added in the non-reactive dependency block. This leaves reactive (webflux) builds without the Pageable dependency and causes compilation failures when x-spring-paginated is used.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
...etstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt
Outdated
Show resolved
Hide resolved
...etstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt
Show resolved
Hide resolved
...enerator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache
Outdated
Show resolved
Hide resolved
Picazsoo
commented
Feb 13, 2026
Contributor
Author
There was a problem hiding this comment.
This was a misunderstanding on my part when I was implementing the declarative client. The class name should definitely match the file name.
…operation-extra-annotation content
padznich
pushed a commit
to padznich/openapi-generator
that referenced
this pull request
Feb 16, 2026
…to feature parity with java-spring codegen; add 'autoXSpringPaginated' option; support x-operation-extra-annotation (OpenAPITools#22958) * add x-kotlin-implements * implement tests * update samples * fix tests - forbidden api issue * add samples * add samples. use Pageable only for server-side * add support for auto-detecting x-spring-paginated in Spring Boot operations * fix maven dependencies import * add unit tests * add support for vendor extension * remove files * fix samples * fix docs * implement suggestions from CR. Fix declarative interface naming. * move import around * add x-operation-extra-annotation * make sure the PageableAsQueryParam does not remove already present x-operation-extra-annotation content * support also list format * regenerate samples and docs * regenerate samples and docs * force tests rerun * remove files * add files * trigger test rerun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves pagination support in the
kotlin-springgenerator by aligning generated controllers with Spring Data Web conventions. fixes #19466It introduces a new
x-spring-paginatedvendor extension that allows an operation to use Spring’sPageableinterface instead of separatepage,size, andsortquery parameters. When enabled, these query parameters are removed from the generated method signature and replaced with a singlePageableargument, resulting in cleaner and more idiomatic Spring controller APIs.In addition, an opt-in
autoXSpringPaginatedconfiguration option is added for cases where the OpenAPI specification cannot be modified (for example, third-party APIs). When enabled, the generator automatically applies the samePageablebehavior to operations that define the standardpage,size, andsortquery parameters.Both features apply only to the
spring-bootserver library, are fully backward compatible, and have no effect unless explicitly enabled. They work consistently across blocking and reactive modes and integrate with existing Spring documentation tooling.important - unless you have api spec which currently contains
x-spring-paginatedorx-operation-extra-annotationthen this will not have an impact on you and is fully backwards compatiblePR 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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Adds x-spring-paginated support to Kotlin Spring and a new autoXSpringPaginated option to align with java-spring. Generates Pageable for Spring Boot servers, supports extra method annotations, removes page/size/sort, fixes declarative interface naming, and updates docs/samples/tests.
New Features
Dependencies
Written for commit f6a2a8b. Summary will update on new commits.