Skip to content

[Kotlin][Spring] fix option useSpringBuiltInValidation not implemented#24115

Merged
wing328 merged 4 commits into
masterfrom
tomas-pecserke-hotfix/kotlin-spring-built-in-validation-option-not-applied
Jun 24, 2026
Merged

[Kotlin][Spring] fix option useSpringBuiltInValidation not implemented#24115
wing328 merged 4 commits into
masterfrom
tomas-pecserke-hotfix/kotlin-spring-built-in-validation-option-not-applied

Conversation

@wing328

@wing328 wing328 commented Jun 24, 2026

Copy link
Copy Markdown
Member

based on #23951 with updated doc, bug fix.

PR checklist

  • Read the contribution guidelines.
  • 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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes the kotlin-spring generator so useSpringBuiltInValidation disables class-level @Validated on generated controllers and interfaces when useBeanValidation is on. Default behavior is unchanged.

  • Bug Fixes
    • Wired the option in KotlinSpringServerCodegen (flag, CLI switch, processOpts/writePropertyBack).
    • Updated api.mustache and apiInterface.mustache to skip the import and annotation when enabled.
    • Added tests for interface/controller and default/true/false cases.
    • Documented the option in docs/generators/kotlin-spring.md.

Written for commit bb4112b. Summary will update on new commits.

Review in cubic

@wing328 wing328 changed the title Tomas pecserke hotfix/kotlin spring built in validation option not applied [Kotlin][Spring] fix option useSpringBuiltInValidation not implemented Jun 24, 2026
@wing328 wing328 added this to the 7.24.0 milestone Jun 24, 2026
@wing328 wing328 marked this pull request as ready for review June 24, 2026 08:35

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java:533">
P1: Missing `writePropertyBack(USE_SPRING_BUILT_IN_VALIDATION, useSpringBuiltInValidation)`. Without it, the flag value never reaches the Mustache template context. When the user explicitly passes `useSpringBuiltInValidation=false`, the String `"false"` left in `additionalProperties` is truthy in Mustache, so `{{^useSpringBuiltInValidation}}` incorrectly fails to render, causing `@Validated` to be skipped despite the flag being false.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@wing328 wing328 merged commit cec5960 into master Jun 24, 2026
15 checks passed
@wing328 wing328 deleted the tomas-pecserke-hotfix/kotlin-spring-built-in-validation-option-not-applied branch June 24, 2026 09:12
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.

2 participants