Do not NPE when array properties items are not specified (#4063)

This commit is contained in:
Nicholas DiPiazza
2016-12-16 05:04:13 -06:00
committed by wing328
parent 2bf3d051a9
commit c6c8ffe4e0

View File

@@ -461,6 +461,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
if (inner == null) {
return null;
}
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
@@ -480,6 +483,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} else {
pattern = "new ArrayList<%s>()";
}
if (ap.getItems() == null) {
return null;
}
return String.format(pattern, getTypeDeclaration(ap.getItems()));
} else if (p instanceof MapProperty) {
final MapProperty ap = (MapProperty) p;