@@ -3813,7 +3813,7 @@ public void customPageableSchemaNotOverridden_issue13052() throws Exception {
38133813 additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
38143814 additionalProperties .put (INTERFACE_ONLY , "true" );
38153815 additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3816-
3816+
38173817 Map <String , File > files = generateFromContract ("src/test/resources/bugs/issue_13052.yaml" , additionalProperties );
38183818
38193819 // Custom Pageable model should be used instead of Spring's Pageable
@@ -3824,6 +3824,155 @@ public void customPageableSchemaNotOverridden_issue13052() throws Exception {
38243824 assertFileContains (petApi .toPath (), "pageable: Pageable" );
38253825 }
38263826
3827+ @ Test
3828+ public void springPaginatedWithNoDocumentationProvider () throws Exception {
3829+ Map <String , Object > additionalProperties = new HashMap <>();
3830+ additionalProperties .put (USE_TAGS , "true" );
3831+ additionalProperties .put (DOCUMENTATION_PROVIDER , "none" );
3832+ additionalProperties .put (INTERFACE_ONLY , "true" );
3833+ additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3834+
3835+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3836+
3837+ // Pageable should be added but no annotation imports
3838+ File petApi = files .get ("PetApi.kt" );
3839+ assertFileContains (petApi .toPath (), "import org.springframework.data.domain.Pageable" );
3840+ assertFileContains (petApi .toPath (), "pageable: Pageable" );
3841+ assertFileNotContains (petApi .toPath (), "import springfox.documentation.annotations.ApiIgnore" );
3842+ assertFileNotContains (petApi .toPath (), "import org.springdoc.api.annotations.ParameterObject" );
3843+ assertFileNotContains (petApi .toPath (), "@ApiIgnore pageable" );
3844+ assertFileNotContains (petApi .toPath (), "@ParameterObject pageable" );
3845+ }
3846+
3847+ @ Test
3848+ public void springPaginatedWithSwagger1AnnotationLibrary () throws Exception {
3849+ Map <String , Object > additionalProperties = new HashMap <>();
3850+ additionalProperties .put (USE_TAGS , "true" );
3851+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springfox" );
3852+ additionalProperties .put (ANNOTATION_LIBRARY , "swagger1" );
3853+ additionalProperties .put (INTERFACE_ONLY , "true" );
3854+ additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3855+
3856+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3857+
3858+ // Test with swagger1 annotations
3859+ File petApi = files .get ("PetApi.kt" );
3860+ assertFileContains (petApi .toPath (), "import org.springframework.data.domain.Pageable" );
3861+ assertFileContains (petApi .toPath (), "import springfox.documentation.annotations.ApiIgnore" );
3862+ assertFileContains (petApi .toPath (), "@ApiParam(hidden = true) pageable: Pageable" );
3863+ }
3864+
3865+ @ Test
3866+ public void springPaginatedNoParamsNoContext () throws Exception {
3867+ Map <String , Object > additionalProperties = new HashMap <>();
3868+ additionalProperties .put (USE_TAGS , "true" );
3869+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
3870+ additionalProperties .put (INTERFACE_ONLY , "true" );
3871+ additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3872+
3873+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3874+
3875+ // Test operation listAllPets which has no parameters except pageable
3876+ File petApi = files .get ("PetApi.kt" );
3877+ assertFileContains (petApi .toPath (), "fun listAllPets(@Parameter(hidden = true) pageable: Pageable)" );
3878+ }
3879+
3880+ @ Test
3881+ public void springPaginatedMixedOperations () throws Exception {
3882+ Map <String , Object > additionalProperties = new HashMap <>();
3883+ additionalProperties .put (USE_TAGS , "true" );
3884+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
3885+ additionalProperties .put (INTERFACE_ONLY , "true" );
3886+ additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3887+
3888+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3889+
3890+ File petApi = files .get ("PetApi.kt" );
3891+
3892+ // Operation with x-spring-paginated should have Pageable
3893+ assertFileContains (petApi .toPath (), "fun findPetsByStatus(" );
3894+ assertFileContains (petApi .toPath (), "pageable: Pageable" );
3895+
3896+ // Operation without x-spring-paginated should NOT have Pageable
3897+ assertFileContains (petApi .toPath (), "fun addPet(" );
3898+ // Verify addPet doesn't have pageable (it has body param only)
3899+ String content = new String (java .nio .file .Files .readAllBytes (petApi .toPath ()));
3900+ String addPetMethod = content .substring (
3901+ content .indexOf ("fun addPet(" ),
3902+ content .indexOf (")" , content .indexOf ("fun addPet(" )) + 1
3903+ );
3904+ Assert .assertFalse (addPetMethod .contains ("pageable" ),
3905+ "addPet should not have pageable parameter" );
3906+ }
3907+
3908+ @ Test
3909+ public void springPaginatedWithServiceInterface () throws Exception {
3910+ Map <String , Object > additionalProperties = new HashMap <>();
3911+ additionalProperties .put (USE_TAGS , "true" );
3912+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
3913+ additionalProperties .put (SERVICE_INTERFACE , "true" );
3914+
3915+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3916+
3917+ // Test that pageable is in service interface
3918+ File petService = files .get ("PetService.kt" );
3919+ if (petService != null ) {
3920+ assertFileContains (petService .toPath (), "import org.springframework.data.domain.Pageable" );
3921+ assertFileContains (petService .toPath (), "pageable: Pageable" );
3922+ }
3923+ }
3924+
3925+ @ Test
3926+ public void springPaginatedParameterOrdering () throws Exception {
3927+ Map <String , Object > additionalProperties = new HashMap <>();
3928+ additionalProperties .put (USE_TAGS , "true" );
3929+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
3930+ additionalProperties .put (INTERFACE_ONLY , "true" );
3931+ additionalProperties .put (SKIP_DEFAULT_INTERFACE , "true" );
3932+ additionalProperties .put (INCLUDE_HTTP_REQUEST_CONTEXT , "true" );
3933+
3934+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3935+
3936+ // Verify exact parameter ordering: allParams -> request -> pageable
3937+ File petApi = files .get ("PetApi.kt" );
3938+ String content = new String (java .nio .file .Files .readAllBytes (petApi .toPath ()));
3939+
3940+ // Find findPetsByStatus method
3941+ int methodStart = content .indexOf ("fun findPetsByStatus(" );
3942+ int methodEnd = content .indexOf ("): ResponseEntity" , methodStart );
3943+ String methodSignature = content .substring (methodStart , methodEnd );
3944+
3945+ // Verify order: status param comes before request, request comes before pageable
3946+ int statusPos = methodSignature .indexOf ("status:" );
3947+ int requestPos = methodSignature .indexOf ("request:" );
3948+ int pageablePos = methodSignature .indexOf ("pageable:" );
3949+
3950+ Assert .assertTrue (statusPos > 0 , "status parameter should exist" );
3951+ Assert .assertTrue (requestPos > statusPos , "request should come after status" );
3952+ Assert .assertTrue (pageablePos > requestPos , "pageable should come after request" );
3953+ }
3954+
3955+ @ Test
3956+ public void springPaginatedDelegateCallPassesPageable () throws Exception {
3957+ Map <String , Object > additionalProperties = new HashMap <>();
3958+ additionalProperties .put (USE_TAGS , "true" );
3959+ additionalProperties .put (DOCUMENTATION_PROVIDER , "springdoc" );
3960+ additionalProperties .put (DELEGATE_PATTERN , "true" );
3961+ additionalProperties .put (INTERFACE_ONLY , "false" );
3962+
3963+ Map <String , File > files = generateFromContract ("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml" , additionalProperties );
3964+
3965+ // Verify that interface method calls delegate with pageable parameter
3966+ File petApi = files .get ("PetApi.kt" );
3967+ String content = new String (java .nio .file .Files .readAllBytes (petApi .toPath ()));
3968+
3969+ // Check for delegate call pattern with pageable
3970+ if (content .contains ("getDelegate().findPetsByStatus" )) {
3971+ assertFileContains (petApi .toPath (), "getDelegate().findPetsByStatus(" );
3972+ assertFileContains (petApi .toPath (), "pageable)" );
3973+ }
3974+ }
3975+
38273976 private Map <String , File > generateFromContract (String url ) throws IOException {
38283977 return generateFromContract (url , new HashMap <>(), new HashMap <>());
38293978 }
0 commit comments