Repository navigation
Description
Is your feature request related to a problem? Please describe.
The Java spring server generator supports Spring Framework 7 API versioning through springApiVersion and the operation-level x-spring-api-version extension, introduced by #22028 for #22027. The kotlin-spring server generator does not currently provide the equivalent behavior.
Checked against current master, commit ad0d57907d3a96a3c450a9b0c1ff6e8c623a5e78 (7.28.0). Kotlin already supports Spring Boot 4, but its generator options, supported extensions, and server @RequestMapping templates do not include API versioning. Searches of existing issues and pull requests did not find a Kotlin Spring request for this feature.
Describe the solution you'd like
Bring the existing Java Spring API-versioning feature to the spring-boot server library of kotlin-spring:
- Add the optional string configuration option
springApiVersionas the default operation mapping version. - Support the existing operation-level
x-spring-api-versionextension. - Preserve Java's precedence: an operation value overrides the global default; an explicitly empty string suppresses the default; an operation extension also works without a global option.
- Generate the optional
versionattribute on@RequestMappingfor normal controllers, interface-only output, and delegate mode, including reactive generation. - Leave unversioned generation unchanged.
- Document the Spring Framework 7+ requirement and use Spring Boot 4 for a generated standalone application. Version resolver configuration remains application-owned.
Example generator configuration:
generatorName: kotlin-spring
library: spring-boot
additionalProperties:
useSpringBoot4: true
springApiVersion: "1.0"An operation may override or suppress that default:
paths:
/versioned:
get:
operationId: getVersioned
x-spring-api-version: "2+"
responses:
'200':
description: OK
/unversioned:
get:
operationId: getUnversioned
x-spring-api-version: ""
responses:
'200':
description: OKThe first operation should generate @RequestMapping(..., version = "2+"); the second should omit the version attribute.
Describe alternatives you've considered
Customizing kotlin-spring/api.mustache and apiInterface.mustache using -t. This requires maintaining local templates and does not provide the global-default processing or discoverable generator option already available for Java Spring.
Additional context
I intend to contribute this as an opt-in parity change with regression tests, generated documentation, and a Spring Boot 4 sample. Header/query mapping constraints through x-version-param and declarative HTTP client versioning are outside this change.
Activity
[kotlin-spring] Add Spring 7 API versioning
[kotlin-spring] Add Spring 7 API versioning