|
19 | 19 | import jakarta.servlet.http.HttpServletRequest; |
20 | 20 | import java.lang.reflect.Field; |
21 | 21 | import java.lang.reflect.Method; |
| 22 | +import java.math.BigDecimal; |
22 | 23 | import java.util.ArrayList; |
23 | 24 | import java.util.HashSet; |
24 | 25 | import java.util.List; |
@@ -132,8 +133,8 @@ public OpenApiCustomizer requiredByDefaultCustomizer() { |
132 | 133 |
|
133 | 134 | Method method = null; |
134 | 135 | for (final String prefix : List.of("get", "is", "has", "")) { |
135 | | - method = ReflectionUtils.findMethod(clazz, !prefix.isEmpty() ? prefix + key.substring(0, 1).toUpperCase() + key.substring(1) : key ); |
136 | | - if (method != null) break; |
| 136 | + method = ReflectionUtils.findMethod(clazz, !prefix.isEmpty() ? prefix + key.substring(0, 1).toUpperCase() + key.substring(1) : key); |
| 137 | + if (method != null) break; |
137 | 138 | } |
138 | 139 |
|
139 | 140 | if (method != null && (method.getAnnotatedReturnType().isAnnotationPresent(Nullable.class) || method.getAnnotatedReturnType().isAnnotationPresent(jakarta.annotation.Nullable.class))) { |
@@ -226,6 +227,27 @@ public Operation customize(final Operation operation, final HandlerMethod handle |
226 | 227 | } |
227 | 228 | } |
228 | 229 |
|
| 230 | + final Parameter pagination = operation.getParameters() == null ? null : operation.getParameters().stream().filter(p -> p.getName().equals("pagination")).findFirst().orElse(null); |
| 231 | + if (pagination != null) { |
| 232 | + operation.getParameters().remove(pagination); |
| 233 | + operation.addParametersItem(new Parameter() |
| 234 | + .name("limit") |
| 235 | + .in("query") |
| 236 | + .description("The maximum amount of items to return") |
| 237 | + .style(Parameter.StyleEnum.FORM) |
| 238 | + .required(false) |
| 239 | + .schema(new StringSchema().minimum(new BigDecimal(1)).maximum(new BigDecimal(25)).example("1")) |
| 240 | + ); |
| 241 | + operation.addParametersItem(new Parameter() |
| 242 | + .name("offset") |
| 243 | + .in("query") |
| 244 | + .description("Where to start searching") |
| 245 | + .style(Parameter.StyleEnum.FORM) |
| 246 | + .required(false) |
| 247 | + .schema(new StringSchema().minimum(new BigDecimal(0)).example("0")) |
| 248 | + ); |
| 249 | + } |
| 250 | + |
229 | 251 | return operation; |
230 | 252 | } |
231 | 253 | } |
|
0 commit comments