better null check in default codegen (#13264)

This commit is contained in:
William Cheng 2022-08-24 23:18:57 +08:00 committed by GitHub
parent 1a5d3926b3
commit 3a2b4b9bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6926,6 +6926,10 @@ public class DefaultCodegen implements CodegenConfig {
final ArraySchema arraySchema = (ArraySchema) schema;
Schema inner = getSchemaItems(arraySchema);
CodegenProperty codegenProperty = fromProperty("property", arraySchema, false);
if (codegenProperty == null) {
throw new RuntimeException("CodegenProperty cannot be null. arraySchema for debugging: " + arraySchema);
}
if (!addSchemaImportsFromV3SpecLocations) {
imports.add(codegenProperty.baseType);
}
@ -6943,6 +6947,10 @@ public class DefaultCodegen implements CodegenConfig {
innerCp = innerCp.items;
}
if (mostInnerItem == null) {
throw new RuntimeException("mostInnerItem (codegen property of array item) cannot be null. " + arraySchema);
}
if (StringUtils.isEmpty(bodyParameterName)) {
if (StringUtils.isEmpty(mostInnerItem.complexType)) {
codegenParameter.baseName = "request_body";