@@ -886,10 +886,14 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
886886 * - Removes the default Spring Data Web pagination query parameters (page, size, sort)
887887 * - Adds appropriate imports (Pageable, ApiIgnore for springfox, ParameterObject for springdoc)
888888 *
889+ * Note: x-spring-paginated is ONLY applied for server-side libraries (spring-boot).
890+ * Client libraries (spring-cloud, spring-declarative-http-interface) need actual query parameters
891+ * to send over HTTP, so the extension is ignored for them.
892+ *
889893 * Parameter ordering in generated methods:
890894 * 1. Regular OpenAPI parameters (allParams)
891895 * 2. Optional HttpServletRequest/ServerWebExchange (if includeHttpRequestContext is enabled)
892- * 3. Pageable parameter (if x-spring-paginated is true)
896+ * 3. Pageable parameter (if x-spring-paginated is true and library is spring-boot )
893897 *
894898 * This implementation mirrors the behavior in SpringCodegen for consistency.
895899 *
@@ -901,34 +905,36 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
901905 */
902906 @ Override
903907 public CodegenOperation fromOperation (String path , String httpMethod , Operation operation , List <io .swagger .v3 .oas .models .servers .Server > servers ) {
904- // add Pageable import only if x-spring-paginated explicitly used
905- // this allows to use a custom Pageable schema without importing Spring Pageable.
906- if (operation .getExtensions () != null && Boolean .TRUE .equals (operation .getExtensions ().get ("x-spring-paginated" ))) {
907- importMapping .putIfAbsent ("Pageable" , "org.springframework.data.domain.Pageable" );
908- }
909-
910908 CodegenOperation codegenOperation = super .fromOperation (path , httpMethod , operation , servers );
911-
912- // add org.springframework.data.domain.Pageable import when needed
913- if (codegenOperation .vendorExtensions .containsKey ("x-spring-paginated" )) {
914- codegenOperation .imports .add ("Pageable" );
915- if (DocumentationProvider .SPRINGFOX .equals (getDocumentationProvider ())) {
916- codegenOperation .imports .add ("ApiIgnore" );
917- }
918- if (DocumentationProvider .SPRINGDOC .equals (getDocumentationProvider ())) {
919- codegenOperation .imports .add ("ParameterObject" );
909+ // Only process x-spring-paginated for server-side libraries (spring-boot)
910+ // Client libraries (spring-cloud, spring-declarative-http-interface) need actual query parameters for HTTP requests
911+ if (SPRING_BOOT .equals (library )) {
912+ // add Pageable import only if x-spring-paginated explicitly used AND it's a server library
913+ // this allows to use a custom Pageable schema without importing Spring Pageable.
914+ if (operation .getExtensions () != null && Boolean .TRUE .equals (operation .getExtensions ().get ("x-spring-paginated" ))) {
915+ importMapping .putIfAbsent ("Pageable" , "org.springframework.data.domain.Pageable" );
920916 }
921917
922- // #8315 Spring Data Web default query params recognized by Pageable
923- List <String > defaultPageableQueryParams = new ArrayList <>(
924- Arrays .asList ("page" , "size" , "sort" )
925- );
918+ // add org.springframework.data.domain.Pageable import when needed (server libraries only)
919+ if (codegenOperation .vendorExtensions .containsKey ("x-spring-paginated" )) {
920+ codegenOperation .imports .add ("Pageable" );
921+ if (DocumentationProvider .SPRINGFOX .equals (getDocumentationProvider ())) {
922+ codegenOperation .imports .add ("ApiIgnore" );
923+ }
924+ if (DocumentationProvider .SPRINGDOC .equals (getDocumentationProvider ())) {
925+ codegenOperation .imports .add ("ParameterObject" );
926+ }
926927
927- // #8315 Remove matching Spring Data Web default query params if 'x-spring-paginated' with Pageable is used
928- codegenOperation . queryParams . removeIf ( param - > defaultPageableQueryParams . contains ( param . baseName ));
929- codegenOperation . allParams . removeIf ( param -> param . isQueryParam && defaultPageableQueryParams . contains ( param . baseName ));
930- }
928+ // #8315 Spring Data Web default query params recognized by Pageable
929+ List < String > defaultPageableQueryParams = new ArrayList <>(
930+ Arrays . asList ( "page" , "size" , "sort" )
931+ );
931932
933+ // #8315 Remove matching Spring Data Web default query params if 'x-spring-paginated' with Pageable is used
934+ codegenOperation .queryParams .removeIf (param -> defaultPageableQueryParams .contains (param .baseName ));
935+ codegenOperation .allParams .removeIf (param -> param .isQueryParam && defaultPageableQueryParams .contains (param .baseName ));
936+ }
937+ }
932938 return codegenOperation ;
933939 }
934940
0 commit comments