Skip to content

JAVA: generating generic list/array property of nested model fails  #3495

Open
@RunCMD159

Description

@RunCMD159
Description

I have a Model A which has a property with type: array that references another Model B which also has a property with type: array and references another Model.
When generating the Model A i get a generic List with Model B but in Model B the referenced Model is not generated and the List $ref string as generic type.

Swagger-codegen version

gradle plugin:
'org.detoeuf.swagger-codegen' version '1.6.1'

Swagger declaration file content or url

ModelA.yaml:
definitions:
ModelA:
type: object
properties:
propertyA:
type: array
items: { $ref: './ModelB.yaml#/definitions/ModelB' }

ModelB.yaml:
definitions:
ModelB:
type: object
properties:
propertyA1:
type: array
items: { $ref: './ModelC.yaml#/definitions/ModelC' }

ModelC.yaml:
definitions:
ModelC:
type: object
properties:
property1: {type: string}
property2: {type: number}
property3: {type: string}

==generated Models==

ModelA:
`public class ModelA {

private List '<'ModelB'>' propertyA = new ArrayList'<'ModelB'>'();`

this is right.

ModelB:
public class ModelB {

private List '<'ModelCYamldefinitionsModelC'>' propertyA1 = new ArrayList '<'ModelCYamldefinitionsModelC'>'();

this not.
And ModelC is not even generated.

Command line used for generation

gradlew swagger

Steps to reproduce

generate the models for a path.

Related issues
Suggest a Fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions