Skip to content

Commit 9262482

Browse files
committed
StackOverflowError when using @ParameterObject on groovy class. Fixes #2426
1 parent 296af61 commit 9262482

File tree

5 files changed

+194
-163
lines changed

5 files changed

+194
-163
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/extractor/MethodParameterPojoExtractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public class MethodParameterPojoExtractor {
9393
SIMPLE_TYPE_PREDICATES.add(Class::isEnum);
9494
SIMPLE_TYPE_PREDICATES.add(Class::isArray);
9595
SIMPLE_TYPE_PREDICATES.add(MethodParameterPojoExtractor::isSwaggerPrimitiveType);
96+
SIMPLE_TYPE_PREDICATES.add(aClass -> aClass.getName().startsWith("org.codehaus.groovy.reflection"));
9697
}
9798

9899
/**

springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarController.groovy

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package test.org.springdoc.api.app1
2222

23+
import org.springdoc.core.annotations.ParameterObject
2324

2425
import org.springframework.web.bind.annotation.GetMapping
2526
import org.springframework.web.bind.annotation.PathVariable
@@ -33,14 +34,18 @@ class CarController {
3334
CarController(CarService carService) {
3435
this.carService = carService
3536
}
37+
38+
@GetMapping(path = 'cars/{carId}')
39+
Car getCar(@PathVariable(value = 'carId') Long carId) {
40+
return carService.getCar(carId)
41+
}
3642

3743
@GetMapping(path = '/cars')
38-
List<Car> getCars() {
44+
List<Car> getCars(@ParameterObject CarsFilter filter) {
3945
return carService.getCars()
4046
}
4147

42-
@GetMapping(path = 'cars/{carId}')
43-
Car getCar(@PathVariable(value = 'carId') Long carId) {
44-
return carService.getCar(carId)
48+
static class CarsFilter {
49+
String name;
4550
}
4651
}

springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarController.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package test.org.springdoc.api.app2
2222

23+
import org.springdoc.core.annotations.ParameterObject
2324

2425
import org.springframework.web.bind.annotation.GetMapping
2526
import org.springframework.web.bind.annotation.PathVariable
@@ -35,10 +36,14 @@ class CarController {
3536
}
3637

3738
@GetMapping(path = '/cars')
38-
List<test.org.springdoc.api.app2.Car> getCars() {
39+
List<test.org.springdoc.api.app1.Car> getCars(@ParameterObject CarsFilter filter) {
3940
return carService.getCars()
4041
}
4142

43+
static class CarsFilter {
44+
String name;
45+
}
46+
4247
@GetMapping(path = 'cars/{carId}')
4348
test.org.springdoc.api.app2.Car getCar(@PathVariable(value = 'carId') Long carId) {
4449
return carService.getCar(carId)

0 commit comments

Comments
 (0)