Skip to content

Commit

Permalink
handle collections in webservice documentation generator
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed May 20, 2024
1 parent 9ce9a7b commit 468bfe1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public Class<?> getType() {
}

public void setType(Class<?> type) {
if (type == null)
throw new RuntimeException("null type");
this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -45,10 +47,15 @@ public static JavaLanguageVariable createVariableFromField(Field field) {
variable.setRequired(isVariableRequired(annotation));
variable.setDescription(getVariableDescription(annotation));
}

if (isClassArrayOrCollection(field.getType()))
variable.setType(field.getType().getComponentType());
else

if (isClassArrayOrCollection(field.getType())) {
if(field.getGenericType() instanceof ParameterizedType aType){
Type[] fieldArgTypes = aType.getActualTypeArguments();
variable.setType((Class)fieldArgTypes[0]);
}else {
variable.setType(field.getType().getComponentType());
}
} else
variable.setType(GenericsUtils.getFieldGenericType(field));
variable.setMultiOccurs(isClassArrayOrCollection(field.getType()));
return variable;
Expand Down

0 comments on commit 468bfe1

Please sign in to comment.