Description
In my API I have an object with two object arrays. When I generate the java classes the first list has the correct list type,
the second has the type "Object", which is wrong.
openapi-generator version
7.2.0
OpenAPI declaration file content or url
openapi: 3.1.0
info:
title: Example
version: 0.0.1
components:
schemas:
ParentObject:
type: object
properties:
listOfChildren1:
type: array
items:
$ref: '#/components/schemas/ChildObject'
listOfChildren2:
type: array
items:
$ref: '#/components/schemas/ChildObject'
listOfChildren3:
type: array
items:
$ref: '#/components/schemas/ChildObject'
ChildObject:
type: object
properties:
testProp:
type: string
Generation Details
Classes are generated with openapi-generator generate -g java -i openapi3_1.yaml -o output
Steps to reproduce
Just generate the classes with the command above.
Suggest a fix
The properties of class "ParentObject" should be a list type, not an object.
This is what's being generated:
public class ParentObject {
public static final String SERIALIZED_NAME_LIST_OF_CHILDREN1 = "listOfChildren1";
@SerializedName(SERIALIZED_NAME_LIST_OF_CHILDREN1)
private List<ChildObject> listOfChildren1;
public static final String SERIALIZED_NAME_LIST_OF_CHILDREN2 = "listOfChildren2";
@SerializedName(SERIALIZED_NAME_LIST_OF_CHILDREN2)
private Object listOfChildren2 = null; //should be of type List<ChildObject>
public static final String SERIALIZED_NAME_LIST_OF_CHILDREN3 = "listOfChildren3";
@SerializedName(SERIALIZED_NAME_LIST_OF_CHILDREN3)
private Object listOfChildren3 = null; //should be of type List<ChildObject>
(...)
but it should be
public class ParentObject {
public static final String SERIALIZED_NAME_LIST_OF_CHILDREN1 = "listOfChildren1";
@SerializedName(SERIALIZED_NAME_LIST_OF_CHILDREN1)
private List<ChildObject> listOfChildren1;
public static final String SERIALIZED_NAME_LIST_OF_CHILDREN2 = "listOfChildren2";
@SerializedName(SERIALIZED_NAME_LIST_OF_CHILDREN2)
private List<ChildObject> listOfChildren2; //correct type
public static final String SERIALIZED_NAME_LIST_OF_CHILDREN3 = "listOfChildren3";
@SerializedName(SERIALIZED_NAME_LIST_OF_CHILDREN3)
private List<ChildObject> listOfChildren3; //correct type
(...)
of course with the right setter and getter methods as these from "listOfChildren1".
Description
In my API I have an object with two object arrays. When I generate the java classes the first list has the correct list type,
the second has the type "Object", which is wrong.
openapi-generator version
7.2.0
OpenAPI declaration file content or url
Generation Details
Classes are generated with
openapi-generator generate -g java -i openapi3_1.yaml -o outputSteps to reproduce
Just generate the classes with the command above.
Suggest a fix
The properties of class "ParentObject" should be a list type, not an object.
This is what's being generated:
but it should be
of course with the right setter and getter methods as these from "listOfChildren1".