@NotNull
	public static Annotation[] getParameterAnnotations(MethodParameter methodParameter) {
		// Get the parameter annotations directly as an array
		Annotation[] annotations = methodParameter.getParameterAnnotations();
		// Return early if no annotations are found, avoiding unnecessary processing
		if (ArrayUtils.isEmpty(annotations)) {
			return new Annotation[0];
		}
		// Create a list that can contain both parameter and meta-annotations
		List<Annotation> resultAnnotations = new ArrayList<>(annotations.length);

		// Add all direct annotations
		resultAnnotations.addAll(List.of(annotations));

		// Process each direct annotation to collect its meta-annotations
		for (Annotation annotation : annotations) {
			// Fetch meta-annotations
			Annotation[] metaAnnotations = annotation.annotationType().getAnnotations();

			// Only add meta-annotations if they exist
			if (ArrayUtils.isNotEmpty(metaAnnotations)) {
				resultAnnotations.addAll(List.of(metaAnnotations));
			}
		}
		// Convert the list to an array and return
		return resultAnnotations.toArray(new Annotation[0]);
	}
Gets parameter annotations.

@param methodParameter the method parameter
@return the parameter annotations
springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java