Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static boolean isConstructorCompatible(Constructor<?> constructor) {
* @return list of Fields
*/
public static List<Field> getDeclaredFields(Class<?> cls) {
if (cls.equals(Object.class)) {
if (cls == null || Object.class.equals(cls)) {
return Collections.emptyList();
}
final List<Field> fields = new ArrayList<Field>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponses;
import io.swagger.reflection.Child;
import io.swagger.reflection.IParent;
import io.swagger.reflection.Parent;
import io.swagger.util.ReflectionUtils;

Expand All @@ -12,6 +13,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collections;

import javax.ws.rs.Path;

Expand Down Expand Up @@ -114,4 +116,10 @@ public void testDerivedAnnotation() {
Assert.assertNotNull(annotation);
Assert.assertEquals(annotation.value(), "parentInterfacePath");
}

@Test
public void getDeclaredFieldsFromInterfaceTest() throws NoSuchMethodException {
final Class cls = IParent.class;
Assert.assertEquals(Collections.emptyList(), ReflectionUtils.getDeclaredFields(cls));
}
}