Fix default value generation for composed schemas in AbstractJavaCodegen (#8918)

This commit is contained in:
Florian Kamella 2021-03-23 17:36:54 +01:00 committed by GitHub
parent 0f981fffc3
commit 03be3c612d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -941,6 +941,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return super.toDefaultValue(schema);
}
return null;
} else if (ModelUtils.isComposedSchema(schema)) {
if (schema.getDefault() != null) {
return super.toDefaultValue(schema);
}
return null;
}
return super.toDefaultValue(schema);

View File

@ -53,13 +53,13 @@ import org.openapitools.client.JSON;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class Drawing {
public static final String JSON_PROPERTY_MAIN_SHAPE = "mainShape";
private Shape mainShape = null;
private Shape mainShape;
public static final String JSON_PROPERTY_SHAPE_OR_NULL = "shapeOrNull";
private ShapeOrNull shapeOrNull = null;
private ShapeOrNull shapeOrNull;
public static final String JSON_PROPERTY_NULLABLE_SHAPE = "nullableShape";
private JsonNullable<NullableShape> nullableShape = JsonNullable.<NullableShape>of(null);
private JsonNullable<NullableShape> nullableShape = JsonNullable.<NullableShape>undefined();
public static final String JSON_PROPERTY_SHAPES = "shapes";
private List<Shape> shapes = null;

View File

@ -54,13 +54,13 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class Drawing extends HashMap<String, Fruit> {
public static final String JSON_PROPERTY_MAIN_SHAPE = "mainShape";
private Shape mainShape = null;
private Shape mainShape;
public static final String JSON_PROPERTY_SHAPE_OR_NULL = "shapeOrNull";
private ShapeOrNull shapeOrNull = null;
private ShapeOrNull shapeOrNull;
public static final String JSON_PROPERTY_NULLABLE_SHAPE = "nullableShape";
private JsonNullable<NullableShape> nullableShape = JsonNullable.<NullableShape>of(null);
private JsonNullable<NullableShape> nullableShape = JsonNullable.<NullableShape>undefined();
public static final String JSON_PROPERTY_SHAPES = "shapes";
private List<Shape> shapes = null;