diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/AbstractJacksonFieldSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/AbstractJacksonFieldSnippet.java index 2f605430..ac14c495 100644 --- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/AbstractJacksonFieldSnippet.java +++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/AbstractJacksonFieldSnippet.java @@ -90,15 +90,15 @@ protected FieldDescriptors createFieldDescriptors(Operation operation, protected Type firstGenericType(MethodParameter param) { Type type = param.getGenericParameterType(); - if(type instanceof TypeVariable) { - TypeVariable tv = (TypeVariable)type; + if (type instanceof TypeVariable) { + TypeVariable tv = (TypeVariable) type; return findTypeFromTypeVariable(tv, param.getContainingClass()); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type actualArgument = parameterizedType.getActualTypeArguments()[0]; - if(actualArgument instanceof Class) { + if (actualArgument instanceof Class) { return actualArgument; - } else if(actualArgument instanceof TypeVariable) { + } else if (actualArgument instanceof TypeVariable) { TypeVariable typeVariable = (TypeVariable)actualArgument; return findTypeFromTypeVariable(typeVariable, param.getContainingClass()); } @@ -109,16 +109,14 @@ protected Type firstGenericType(MethodParameter param) { } protected Type findTypeFromTypeVariable(TypeVariable typeVariable, Class clazz) { - Type defaultReturnValue = Object.class; - String variableName = typeVariable.getName(); Map typeMap = GenericTypeResolver.getTypeVariableMap(clazz); - for(TypeVariable tv : typeMap.keySet()) { - if(StringUtils.equals(tv.getName(), variableName)) { + for (TypeVariable tv : typeMap.keySet()) { + if (StringUtils.equals(tv.getName(), variableName)) { return typeMap.get(tv); } } - return defaultReturnValue; + return Object.class; } protected abstract Type getType(HandlerMethod method);