Skip to content

Commit ae0d3a9

Browse files
author
m2
committed
feat: type-use for method parameters
1 parent 88e78ae commit ae0d3a9

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,23 +618,21 @@ public void applyBeanValidatorAnnotations(final MethodParameter methodParameter,
618618
Schema<?> schema = parameter.getSchema();
619619
SchemaUtils.applyValidationsToSchema(schema, annotations);
620620
if (schema instanceof ArraySchema && methodParameter instanceof DelegatingMethodParameter mp) {
621+
java.lang.reflect.AnnotatedType annotatedType = null;
621622
if (isParameterObject) {
622623
Field field = mp.getField();
623-
if (field != null && field.getAnnotatedType() instanceof AnnotatedParameterizedType paramType) {
624-
java.lang.reflect.AnnotatedType[] typeArgs = paramType.getAnnotatedActualTypeArguments();
625-
for (java.lang.reflect.AnnotatedType typeArg : typeArgs) {
626-
List<Annotation> genericAnnotations = Arrays.stream(typeArg.getAnnotations()).toList();
627-
SchemaUtils.applyValidationsToSchema(schema.getItems(), genericAnnotations);
628-
}
624+
if (field != null) {
625+
annotatedType = field.getAnnotatedType();
629626
}
630627
} else {
631628
java.lang.reflect.Parameter param = mp.getParameter();
632-
if (param.getAnnotatedType() instanceof AnnotatedParameterizedType paramType) {
633-
java.lang.reflect.AnnotatedType[] typeArgs = paramType.getAnnotatedActualTypeArguments();
634-
for (java.lang.reflect.AnnotatedType typeArg : typeArgs) {
635-
List<Annotation> genericAnnotations = Arrays.stream(typeArg.getAnnotations()).toList();
636-
SchemaUtils.applyValidationsToSchema(schema.getItems(), genericAnnotations);
637-
}
629+
annotatedType = param.getAnnotatedType();
630+
}
631+
if (annotatedType instanceof AnnotatedParameterizedType paramType) {
632+
java.lang.reflect.AnnotatedType[] typeArgs = paramType.getAnnotatedActualTypeArguments();
633+
for (java.lang.reflect.AnnotatedType typeArg : typeArgs) {
634+
List<Annotation> genericAnnotations = Arrays.stream(typeArg.getAnnotations()).toList();
635+
SchemaUtils.applyValidationsToSchema(schema.getItems(), genericAnnotations);
638636
}
639637
}
640638
}

0 commit comments

Comments
 (0)