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

Custom object as query param annotated with @Validated is treated like a part of RequestBody #2513

Closed
Roggired opened this issue Feb 18, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@Roggired
Copy link

Describe the bug

Spring Web MVC supports objects of custom classes to be used as query params. The framework maps fields of such object to appropriate query params. springdoc-openapi handles this case correctly. However, if controller's argument of custom class is annotated with @Validated, springdoc-openapi generates the description of this parameter like a part of a request body instead of treating it as query params.

To Reproduce
Steps to reproduce the behavior:

  • Spring Boot 3.1.3
  • org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0
  • Write a rest controller with following method:
    @PostMapping("/filtered")
    fun getCoursePageFiltered(
        @Validated pageParams: PageParams,
        @Validated @RequestBody request: CoursesFilteredRequest,
    ): PageView<CourseTableInfo> = courseStructureService.getCoursePageFiltered(
        request = request,
        pageParams = pageParams
    ).toView()
  • Run Spring Boot application and open Swagger UI page in a browser.

Expected behavior
Expected the same output like the library generates in case if there is no @Validated annotation on PageParams method argument.
image

Actual behavior
image

@bnasslahsen
Copy link
Contributor

@Roggired,

This issue is similar to #2519
Should be now fixed with the latest SNAPHSOT

@bnasslahsen bnasslahsen added the duplicate This issue or pull request already exists label Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants