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
  • #12726
Closed
Open
Issue created Jun 28, 2022 by Administrator@rootContributor

[REQ] [SPRING] Add support for request parameter pattern validation

Created by: LubomirS

Is your feature request related to a problem? Please describe.

Open api v3 spec allows defining patterns in schemas, which includes places like pathParams, queryParams and headerParams. There already is support for pattern validation in both pathParams and queryParams, however, this validation cannot be used for headers. Example:

{
  "name": "patternHeader",
  "in": "header",
  "required": true,
  "schema": {
    "pattern": "[0-9]+",
    "type": "string"
  }
}

In Spring, request header would be annotated with javax.validation.constraints.Pattern, like so:

@RequestHeader(value = "patternHeader") @Pattern(regexp = "[0-9]+") String patternHeader

which will validate if the request header matches the regex "[0-9]+".

Describe the solution you'd like

I would propose to add this feature by adding the beanValidationHeaderParams mustache file for Spring codegen, similarly how it's done with query params.

Describe alternatives you've considered

I don't think there is a better alternative solution to support this validation.

Additional context

Assignee
Assign to
Time tracking