-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JAVA: generating generic list/array property of nested model fails #3495
Comments
I think the issue is related to #3305 |
As a workaround, defining the models within the same file (spec) should work without issue. |
I am having this issue as well. But my spec is huge, so I can't specify in the same file. |
I have this issue as well and it is critical to our use of swagger. Our spec is huge, so we must split our spec into multiple files. |
Another possible workaround (as mentioned in #3305) is to revert Swagger Parser version to 1.0.19 |
The issue is also present with *.json definitions, and downgrading Swagger Parser version didn`t help =( The only difference in our case is the type being "object" in nested references, not "array" |
Can you guys please pull the latest master to give it a try (as a newer stable version of Swagger parser has been released)? |
Hi, wing328! Seems like the problem is still there, but it looks differently (or might be another one, not sure). Let us have models A1 and A2, each of A-models referencing model B. Model B, in turn, references model C (../Path/to/C.json#/definitions/C):
|
@dennisTS thanks for performing more tests to confirm. Do you mind sharing with me the spec so that I can more easily reproduce the issue? If the spec cannot be shared publicly, please send it to wing328@yahoo.com (email address stated in my github profile) |
@wing328 Nested_references_API.zip - here is a stub definition to reproduce the issue |
@wing328 just checked - it is a separate issue =( the one described by FlorianSchmuck still exists |
I tried with the latest version swagger-codegen-cli-3.0.0-rc0 and still see the missing imports for the nested arrays. Is there any solution released yet? |
@vidyas78 can you please share the command and spec you use to get the error? |
api.yaml definition contains the "array of array" definition, swagger: '2.0'
Command to generate: java -jar libs/swagger-codegen-cli-3.0.0-rc0.jar generate -l java -i api.yaml -o target Once the files are generated , I see missing imports for WaveformsUpdate and mvn clean install fails due to that. Thanks |
thanks @vidyas78 , since this is for 3.0.0, can you please file a new ticket with these info and tag me there? i'll address the issue. |
sure will do it. We are currently using 2.2.3 for my project and to overcome this issue, I was trying all the later versions until 3.0.0. Do you know any specific version where this issue is fixed? Or any workaround? |
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
The text was updated successfully, but these errors were encountered: