diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/MethodParameterPojoExtractor.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/MethodParameterPojoExtractor.java index 8edfdd6b2..8b97c4cbd 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/MethodParameterPojoExtractor.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/MethodParameterPojoExtractor.java @@ -174,9 +174,8 @@ private static Stream fromSimpleClass(Class paramClass, Fiel try { Parameter parameter = field.getAnnotation(Parameter.class); boolean isNotRequired = parameter == null || !parameter.required(); - Annotation[] finalFieldAnnotations = fieldAnnotations; - if ("java.lang.Record".equals(paramClass.getSuperclass().getName())) { + if (paramClass.getSuperclass() != null && "java.lang.Record".equals(paramClass.getSuperclass().getName())) { Method classGetRecordComponents = Class.class.getMethod("getRecordComponents"); Object[] components = (Object[]) classGetRecordComponents.invoke(paramClass); @@ -191,7 +190,7 @@ private static Stream fromSimpleClass(Class paramClass, Fiel .filter(method -> method.getName().equals(field.getName())) .map(method -> new MethodParameter(method, -1)) .map(methodParameter -> DelegatingMethodParameter.changeContainingClass(methodParameter, paramClass)) - .map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), finalFieldAnnotations, true, isNotRequired)); + .map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), fieldAnnotations, true, isNotRequired)); } else @@ -201,7 +200,7 @@ private static Stream fromSimpleClass(Class paramClass, Fiel .filter(Objects::nonNull) .map(method -> new MethodParameter(method, -1)) .map(methodParameter -> DelegatingMethodParameter.changeContainingClass(methodParameter, paramClass)) - .map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), finalFieldAnnotations, true, isNotRequired)); + .map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), fieldAnnotations, true, isNotRequired)); } catch (IntrospectionException | NoSuchMethodException | InvocationTargetException | IllegalAccessException |