@@ -3678,7 +3678,6 @@ public void springPaginatedWithSpringDoc() throws Exception {
36783678
36793679 File petApi = files .get ("PetApi.kt" );
36803680 assertFileContains (petApi .toPath (), "import org.springframework.data.domain.Pageable" );
3681- assertFileContains (petApi .toPath (), "import org.springdoc.api.annotations.ParameterObject" );
36823681 assertFileContains (petApi .toPath (), "pageable: Pageable" );
36833682 assertFileContains (petApi .toPath (), "@Parameter(hidden = true) pageable: Pageable" );
36843683 }
@@ -3696,7 +3695,6 @@ public void springPaginatedWithSpringDocAndSpringBoot3() throws Exception {
36963695
36973696 File petApi = files .get ("PetApi.kt" );
36983697 assertFileContains (petApi .toPath (), "import org.springframework.data.domain.Pageable" );
3699- assertFileContains (petApi .toPath (), "import org.springdoc.core.annotations.ParameterObject" );
37003698 assertFileContains (petApi .toPath (), "pageable: Pageable" );
37013699 }
37023700
@@ -3862,6 +3860,49 @@ public void springPaginatedWithSwagger1AnnotationLibrary() throws Exception {
38623860 assertFileContains (petApi .toPath (), "@ApiParam(hidden = true) pageable: Pageable" );
38633861 }
38643862
3863+ @ Test
3864+ public void springPaginatedWithSpringDocUsesPageableAsQueryParam () throws Exception {
3865+ Map <String , Object > additionalProperties = new HashMap <>();
3866+ additionalProperties .put (USE_TAGS , "true" );
3867+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
3868+ additionalProperties .put (INTERFACE_ONLY , "true" );
3869+ additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3870+
3871+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3872+
3873+ File petApi = files .get ("PetApi.kt" );
3874+ String content = Files .readString (petApi .toPath ());
3875+
3876+ // Verify @PageableAsQueryParam annotation is present at method level
3877+ assertFileContains (petApi .toPath (), "import org.springdoc.core.converters.models.PageableAsQueryParam" );
3878+ assertFileContains (petApi .toPath (), "@PageableAsQueryParam" );
3879+
3880+ // Verify Pageable parameter has @Parameter(hidden = true)
3881+ assertFileContains (petApi .toPath (), "@Parameter(hidden = true) pageable: Pageable" );
3882+
3883+ // Verify the annotation appears before @RequestMapping for findPetsByStatus
3884+ int findPetsByStatusStart = content .indexOf ("fun findPetsByStatus(" );
3885+ Assert .assertTrue (findPetsByStatusStart > 0 , "findPetsByStatus method should exist" );
3886+
3887+ String methodBlock = content .substring (Math .max (0 , findPetsByStatusStart - 1000 ), findPetsByStatusStart );
3888+ int pageableAsQueryParamPos = methodBlock .lastIndexOf ("@PageableAsQueryParam" );
3889+ int requestMappingPos = methodBlock .lastIndexOf ("@RequestMapping" );
3890+
3891+ Assert .assertTrue (pageableAsQueryParamPos > 0 , "@PageableAsQueryParam should be present before method" );
3892+ Assert .assertTrue (requestMappingPos > pageableAsQueryParamPos ,
3893+ "@PageableAsQueryParam should appear before @RequestMapping" );
3894+
3895+ // Verify page, size, sort parameters are NOT in the method signature
3896+ String methodSignature = content .substring (findPetsByStatusStart ,
3897+ content .indexOf ("): ResponseEntity" , findPetsByStatusStart ));
3898+ Assert .assertFalse (methodSignature .contains ("page:" ),
3899+ "page parameter should be removed from method signature" );
3900+ Assert .assertFalse (methodSignature .contains ("size:" ) && methodSignature .contains ("@RequestParam" ),
3901+ "size query parameter should be removed from method signature" );
3902+ Assert .assertFalse (methodSignature .contains ("sort:" ),
3903+ "sort parameter should be removed from method signature" );
3904+ }
3905+
38653906 @ Test
38663907 public void springPaginatedNoParamsNoContext () throws Exception {
38673908 Map <String , Object > additionalProperties = new HashMap <>();
0 commit comments