From fbe768bb9c57aefc64fd5946a3b647b6773b9dac Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 7 Jun 2023 15:23:58 +0800 Subject: [PATCH] minor refactoring on default codegen (#15777) --- .../org/openapitools/codegen/DefaultCodegen.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index c95c95b28fa..3cecbc9347d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -7227,10 +7227,6 @@ 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"; @@ -8147,7 +8143,9 @@ public class DefaultCodegen implements CodegenConfig { * @return Schema the input data converted to a Schema if possible */ protected Schema getSchemaFromBooleanOrSchema(Object schema) { - if (schema instanceof Boolean) { + if (schema == null) { + return null; + } else if (schema instanceof Boolean) { if (Boolean.TRUE.equals(schema)) { return trueSchema; } else if (Boolean.FALSE.equals(schema)) { @@ -8156,13 +8154,9 @@ public class DefaultCodegen implements CodegenConfig { // null case return null; } else if (schema instanceof Schema) { - if (schema == null) { - return null; - } return (Schema) schema; - } else if (schema == null) { - return null; + } else { + throw new IllegalArgumentException("Invalid schema type; type must be Boolean or Schema"); } - throw new IllegalArgumentException("Invalid schema type; type must be Boolean or Schema"); } }