Skip to content

[spring] Add support for request parameter pattern validation #12732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LubomirS
Copy link
Contributor

@LubomirS LubomirS commented Jun 29, 2022

…dation in spring codegen

Support for bean validation annotations for request headers was added in spring codegen, similarly how it currently works for query params. This implements the issue #12726

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    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*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the master: master (6.0.1) (patch release), 6.1.x (breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente

@wing328 wing328 changed the title Feat/12726 [spring] Add support for request parameter pattern validation Jul 11, 2022
@wing328 wing328 added this to the 6.1.0 milestone Jul 11, 2022
# Conflicts:
#	modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
@wing328 wing328 modified the milestones: 6.1.0, 6.1.1 Sep 11, 2022
operationId: headerBeanValidation
tags:
- headers
parameters:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test case with Optional will also be interesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MelleD , I am not sure I understand, the second header is optional

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no i mean the java Optional type. That you generate something like
e.g. Optional<@Pattern() String>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally not use Optional<> for a request header/parameter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LubomirS somebody else might use Optional here, so please add a test case for that

@wing328 wing328 modified the milestones: 6.1.1, 6.2.1 Sep 24, 2022
@wing328 wing328 modified the milestones: 6.2.1, 6.3.0 Nov 1, 2022
@wing328 wing328 modified the milestones: 6.3.0, 6.3.1 Jan 20, 2023
@wing328 wing328 modified the milestones: 6.4.0, 6.5.0 Feb 19, 2023
{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}}{{>paramDoc}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isHeaderParam}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only header parameters? why about request & form parameters?

@wing328 wing328 modified the milestones: 6.5.0, 6.6.0 Apr 1, 2023
@wing328 wing328 modified the milestones: 6.6.0, 7.0.0 May 11, 2023
@wing328 wing328 modified the milestones: 7.0.0, 7.0.1 Aug 25, 2023
@wing328 wing328 modified the milestones: 7.0.1, 7.1.0 Sep 20, 2023
@wing328 wing328 removed this from the 7.1.0 milestone Nov 13, 2023
@wing328 wing328 added this to the 7.2.0 milestone Nov 13, 2023
@wing328 wing328 modified the milestones: 7.2.0, 7.3.0 Dec 22, 2023
@wing328 wing328 modified the milestones: 7.3.0, 7.4.0 Feb 8, 2024
@wing328 wing328 modified the milestones: 7.4.0, 7.5.0 Mar 11, 2024
@wing328 wing328 modified the milestones: 7.5.0, 7.6.0 Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants