Fix NPEs in Java generator (#154)

This commit is contained in:
delenius 2018-05-26 02:42:02 -07:00 committed by William Cheng
parent 4d7ff8cfbd
commit 7db0201a89

View File

@ -1459,7 +1459,7 @@ public class DefaultCodegen implements CodegenConfig {
}
// parent model
final String parentName = getParentName(composed, allDefinitions);
final Schema parent = StringUtils.isBlank(parentName) ? null : allDefinitions.get(parentName);
final Schema parent = StringUtils.isBlank(parentName) || allDefinitions == null ? null : allDefinitions.get(parentName);
List<Schema> interfaces = getInterfaces(composed);
@ -4097,7 +4097,12 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.isListContainer = true;
codegenParameter.description = s.getDescription();
codegenParameter.dataType = getTypeDeclaration(s);
codegenParameter.datatypeWithEnum = codegenParameter.dataType.replace(codegenParameter.baseType, codegenParameter.enumName);
if (codegenParameter.baseType != null && codegenParameter.enumName != null){
codegenParameter.datatypeWithEnum = codegenParameter.dataType.replace(codegenParameter.baseType, codegenParameter.enumName);
}
else {
LOGGER.warn("Could not compute datatypeWithEnum from " + codegenParameter.baseType + ", " + codegenParameter.enumName);
}
//TODO fix collectformat for form parameters
//collectionFormat = getCollectionFormat(s);
// default to csv: