I am using a Pageable as a method parameter in a spring webflux controller. I wanted to be able to override the default page size and the max size of the Pageable do a configurable property. I can do this using setters on the ReactivePageableHandlerMethodArgumentResolver, as setting global properties does not work for pageable in a webflux app, only in a webmvc one.
@Component
@RequiredArgsConstructor
public class CustomConfig implements WebFluxConfigurer {
// a ConfigurationProperties class that holds the customisable values
private final PageableProperties pageableProperties;
@Override
public void configureArgumentResolvers(final ArgumentResolverConfigurer configurer) {
final var resolver = new ReactivePageableHandlerMethodArgumentResolver();
resolver.setMaxPageSize(pageableProperties.getMaxPageSize());
resolver.setFallbackPageable(Pageable.ofSize(pageableProperties.getDefaultPageSize()));
configurer.addCustomResolver(resolver);
}
}
However openapi still displays the default value as 20, even if this is not the case. I am using the annotation @ParameterObject for OpenAPI to create the various sections for the pageable properties.
public Mono<String> doSomething(@ParameterObject final Pageable ageable)
{
//some logic
}
If I add the @PageableDefault(size = 100) after the @ParameterObject, I can override the defaut page size that appears in the openapi docs, but this requires a constant rather than coming from a configurable property.
If I add @PageableDefault without the size attribute, then it defaults to 10.
Is there any way to either get openapi to be able to use a dynamic value for the default page size, or to remove the default value entirely from the openapi docs?