Skip to content

Marking required path parameters as @NotNull#21951

Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom
GregDThomas:mark-path-params-not-null
Sep 13, 2025
Merged

Marking required path parameters as @NotNull#21951
wing328 merged 1 commit intoOpenAPITools:masterfrom
GregDThomas:mark-path-params-not-null

Conversation

@GregDThomas
Copy link
Contributor

This fixes #21921 by marking required path parameters as @NotNull

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 || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • 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 (2022/02)
@welshm (2022/02)
@MelleD (2022/02)
@atextor (2022/02)
@manedev79 (2022/02)
@javisst (2022/02)
@borsch (2022/02)
@Zomzog (2022/09)
@martin-mfg (2023/08)

@@ -1 +1 @@
{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} No newline at end of file
{{#required}}@NotNull {{/required}}{{>beanValidationCore}} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the PR

do we need the {{#required}} ... {{/required}} check given that path parameters are always required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes a lot of sense now you say it! I’ll get to that as soon as I’m online properly.

@GregDThomas GregDThomas force-pushed the mark-path-params-not-null branch from 1be3ac8 to 51360f6 Compare September 13, 2025 09:32
@wing328 wing328 merged commit ec28d62 into OpenAPITools:master Sep 13, 2025
63 checks passed
@wing328
Copy link
Member

wing328 commented Sep 13, 2025

thanks for the PR
which has been merged

@GregDThomas
Copy link
Contributor Author

Thank you :)

@GregDThomas GregDThomas deleted the mark-path-params-not-null branch September 13, 2025 10:54
@wing328 wing328 changed the title Fix #21921 by marking required path parameters as @NotNull Marking required path parameters as @NotNull Sep 16, 2025
@wing328 wing328 added this to the 7.16.0 milestone Sep 16, 2025
Goopher pushed a commit to Goopher/openapi-generator that referenced this pull request Sep 16, 2025
rajvesh pushed a commit to rajvesh/openapi-generator that referenced this pull request Dec 25, 2025
@kolomanschaft
Copy link

kolomanschaft commented Feb 11, 2026

Adding/Removing validation constraints is a breaking change. If the implementing controller does not match the constraints configuration, that causes runtime errors. I would have saved this one for a major release. Plus, you changed it only for the spring Java generator. All other 15 Java/Kotlin generators behave the old way.

@wing328
Copy link
Member

wing328 commented Mar 3, 2026

Merged #23096 to add an option additionalNotNullAnnotations to include additional @NotNull annotations

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.

[BUG] [Java] [Spring Boot] Required path params not marked NotNull

3 participants