[REQ] [JavaSpring] Header based API operation versioning
Is your feature request related to a problem? Please describe.
We would like version the behavior of an API operation, for which the desired distinction was decided to be sent via an API header, but the latest server generator does not generate the header parameter for the RequestMapping annotation, thus Spring cannot distinguish between the different version implementations.
...
@Operation(
operationId = "getSomeTag",
tags = { "SomeTag" },
responses = {
@ApiResponse(responseCode = "200", description = "OK")
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/some/dummy/endpoint",
this does not get generated into the class --> headers = { "v2HeaderParam" }
)
default ResponseEntity<SomeTagV2> getSomeTagV2(...)
...
@Operation(
operationId = "getSomeTag",
tags = { "SomeTag" },
responses = {
@ApiResponse(responseCode = "200", description = "OK")
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/some/dummy/endpoint"
)
default ResponseEntity<SomeTag> getSomeTag(...)
...
Describe the solution you'd like
Change the Api.mustache template to include required header parameters into the RequestMappings annotation. To achieve this the CodegenOperationModel members have to be aligned to contain the required headers too (currently there are only members for headers and required parameters, which are not eligible for the template controls).
Describe alternatives you've considered
Using Api versioning or a different resource is for some use cases not an option.
Additional context
N/A