minor refactoring on default codegen (#15777)

This commit is contained in:
William Cheng 2023-06-07 15:23:58 +08:00 committed by GitHub
parent 87be942247
commit fbe768bb9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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");
}
}