Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14837
Closed
Open
Issue created Feb 28, 2023 by Noémi Czuczy@listopad7

[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

Assignee
Assign to
Time tracking