Skip to content

Commit 281c896

Browse files
committed
fix defaultValue when using @PageableDefault together with one-indexed-parameters
1 parent 38b78d6 commit 281c896

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/DataRestDelegatingMethodParameterCustomizer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464

6565
/**
6666
* The type Data rest delegating method parameter customizer.
67+
*
68+
* @author bnasslahsen
69+
* @author pheyken
6770
*/
6871
public class DataRestDelegatingMethodParameterCustomizer implements DelegatingMethodParameterCustomizer {
6972

@@ -1131,8 +1134,13 @@ else if (isSpringDataWebPropertiesPresent())
11311134
defaultValue = defaultSchemaVal;
11321135
break;
11331136
case "page":
1134-
if (pageableDefault != null)
1135-
defaultValue = String.valueOf(pageableDefault.page());
1137+
if (pageableDefault != null) {
1138+
if (isSpringDataWebPropertiesPresent() && optionalSpringDataWebPropertiesProvider.get().getSpringDataWebProperties().getPageable().isOneIndexedParameters()) {
1139+
defaultValue = String.valueOf(pageableDefault.page() + 1);
1140+
} else {
1141+
defaultValue = String.valueOf(pageableDefault.page());
1142+
}
1143+
}
11361144
else if (isSpringDataWebPropertiesPresent() && optionalSpringDataWebPropertiesProvider.get().getSpringDataWebProperties().getPageable().isOneIndexedParameters())
11371145
defaultValue = "1";
11381146
else

0 commit comments

Comments
 (0)