Open papaanoel opened 6 years ago
what is the solution for this?
I was poking around and found a way to get past this issue. I'm sharing this in case someone wants to take this and create a proper PR:
I made the changes bellow on the com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader#parseMethod method:
// process parameters
Class[] parameterTypes = method.getParameterTypes();
Annotation[][] paramAnnotations = method.getParameterAnnotations();
DefaultParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
String[] parameterNames = parameterNameDiscoverer.getParameterNames(method);
// paramTypes = method.getParameterTypes
// genericParamTypes = method.getGenericParameterTypes
for (int i = 0; i < parameterTypes.length; i++) {
Type type = parameterTypes[i];
List<Annotation> annotations = Arrays.asList(paramAnnotations[i]);
List<Parameter> parameters = getParameters(type, annotations);
for (Parameter parameter : parameters) {
if(parameter.getName().isEmpty()) {
parameter.setName(parameterNames[i]);
}
operation.parameter(parameter);
}
}
swagger-maven-plugin:3.1.6:generate
maven goal throws a NullPointerException when using generics in requestBody params :Here is the pattern i'm trying to achieve :
and
Thanks.