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

When an entity class contains fields of Class<?> type, an infinite loop occurs #2591

Closed
wenqiuhan opened this issue May 11, 2024 · 1 comment

Comments

@wenqiuhan
Copy link

wenqiuhan commented May 11, 2024

Describe the bug

I placed a variable of Class<?> type in the entity class, and used @ParameterObject annotation for the parameters in the controller. At this point, an infinite loop appeared. Here is a simple example project:springdoc-infinite-loop-bug
(This description is machine translation. If you cannot understand, please reply to me and I will try using other descriptions for translation. Sorry~~)

Student.java

package com.wenqiuhan.springdoc;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
public class Student  {
    private Class<?> entityClass;
}

TestController.java

package com.wenqiuhan.springdoc;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/test")
public class TestController {
    @GetMapping("")
    public String test(@ParameterObject Student student) {
        return "ok";
    }
}

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    3.2.5

  • What modules and versions of springdoc-openapi are you using?
    2.5.0

  • Provide with a sample code (HelloController) or Test that reproduces the problem
    a example project : springdoc-infinite-loop-bug

Screenshots
image

@bnasslahsen
Copy link
Contributor

@wenqiuhan,

This is a missusage of @ParameterObject, which should be used for simple types.
A fix is added, to avoid this error.

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

No branches or pull requests

2 participants