Skip to content
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

[BUG][KOTLIN-SPRING] Missing Bean Validation annotations on RequestBody #16738

Closed
Fabii547 opened this issue Oct 5, 2023 · 1 comment · Fixed by #16859
Closed

[BUG][KOTLIN-SPRING] Missing Bean Validation annotations on RequestBody #16738

Fabii547 opened this issue Oct 5, 2023 · 1 comment · Fixed by #16859

Comments

@Fabii547
Copy link

Fabii547 commented Oct 5, 2023

Description

The kotlin-spring generator does not add beanValidation annotations (e.g. @Max) for RequestBody params.

openapi-generator version

7.0.1

OpenAPI declaration file content or url
paths:
  /add:
    put:
      requestBody:
        content:
          application/json:
            schema:
              type: integer
              title: quantity
              minimum: 2
        required: true
      responses:
        '204':
          description: OK

generates

@RequestMapping(
           method = [RequestMethod.PUT],
            value = ["/add"],
            produces = ["application/json"],
            consumes = ["application/json"]
    )
    fun add(@Valid @RequestBody body: kotlin.Int): ResponseEntity<Unit>

but should have @Min(2) included:

fun add(@Valid @Min(2) @RequestBody body: kotlin.Int): ResponseEntity<Unit>
Generation Details

Plugin configuration: (beanValidation is enabled by default)

generatorName = 'kotlin-spring'
configOptions = [
interfaceOnly: 'true',
skipDefaultInterface: 'true',
useSpringBoot3: 'true'
]

Steps to reproduce

./gradlew openApiGenerate

Related issues/PRs

The same issue occurred and has been fixed in the java spring generator: #13932

Suggest a fix

Applying the same fix as done in #13932 for the java spring version.

@lukbaran
Copy link
Contributor

Hi, I try to fix it in #16859

wing328 pushed a commit that referenced this issue Nov 8, 2023
#16859)

* fix missing bean validation annotations on RequestBody

* add new line to files

* remove new line from files

* reformat file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants