-
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
Nested array data type missing import and fails in build #7812
Comments
@vidyas78 the yaml you pasted is completely flat and missing indentation, can't really be used that way. |
As mentioned by @webron it is hard to follow what your input spec is. Please try the latest As far as I know, in Java |
Please see the yaml content inserted as code this time. Hope the indentation is taken care now. `swagger: '2.0'
|
Tried the same with "swagger-codegen-cli-3.0.0-20180307.151249-37.jar" & still issue exist. If you replace the array of array definition to array of waveformsupdate you can see the swagger-codegen-cli inserts the below import in FormsApi.java import io.swagger.client.model.WaveformsUpdate; |
Without indentation, it is to hard to follow. Please edit your messages. Have a look at the markdown syntax guide. For multiline code, you need to use 3 grave accent. As alternative, you can also save your spec example at http://gist.github.com/ and then add the link here. |
https://gist.github.com/vidyas78/737441244829907cd961ce2a986ec94c Please refer from above & let me know if this helps, the yaml was validated in https://editor.swagger.io//. |
Team Can you please acknowledge if the issue was reproducible at your end? Thanks |
I am sorry but I am not able to follow. I have generated code using the When I look at
This includes the expected Maybe I missed something from your bug description. You have described 2 cases. Maybe the one you posted as gist is the one working... |
Ooops you are right, I made the revision 2 in gist by updating as array[array]. Please generate the same way and you can see the missing import for <List<List>>. |
I have tried your example with the latest version I have found an other issue: #7863
The imports look also good regarding |
Yes imports of the model classes are missing, Can you please share the swagger-codegen-cli version once its fixed? Thanks |
Forget what I have told about the other issues. I think your problem is different and I think I have found a solution. About the swagger-codegen-cli version containing the fix: I am only a contributor to the project, submitting pull request. I can not influence when they are merged. Improving |
I have propsed a pull request to solve your issue: swagger-api/swagger-codegen-generators#44 |
Thanks |
You need to work until the 2 merge requests proposed here are reviewed and merged:
I hope this will be addressed soon. Of course you can fetch my branches and build locally. Be aware that you need to add all maven modules in the same maven build. This pom might help you. I am sorry but I did not keep the jars (I am already working on other issues). |
I have a similar issue #7918. |
This can probably be back-ported, but the repos are different, so it means the the work needs to be done twice. I have no interest to do it myself. You can work and load v2 Spec with version |
@jmini Now that the PR is merged, please help me understand how do I generate the cli jar from source? My understanding is download the latest source code of |
In v3, the The next If you are using the maven plugin. I think that if you run your build with @msjoshi: do not hesitate to ask if you need something. |
A build of the v3 branch was triggered with commit a33c06d. This means that if you download |
@webron, @HugoMario can you please add |
@jmini Let me know if I did this correctly. I verified in pom.xml for
And pom for
Then I ran However, it did not resolve the nested array issue. When I try to compile the client, it would give an error.
|
The snapshot Builds are here: Now the latest build is As explained in the README, you can download it with:
(or manually click on "save link as..." and indicate To test it (in your
Then to generate assuming that
For me it works with this spec provided by @vidyas78 I could run Second verification: file @msjoshi: There is no need to continue the discussion here. #7918 might be a similar but other problem. Test your case with the |
Hi Jmini, I tried my spec with swagger-codegen-cli-3.0.0-20180328.065958-50.jar but import is still missing in the API. Was wondering how it works for you, am I using the right cli? thanks |
Sorry for missing the version, its working with swagger-codegen-cli-3.0.0-20180328.154333-52.jar. Thanks |
@webron, @HugoMario can you please add |
Thanks @jmini. |
@HugoMario
Description
When we define nested arrays (arrays containing arrays) in yaml file and later generate code , it fails to import the inner array type model. This causes build failure.
Swagger-codegen version
swagger-codegen-cli-3.0.0-rc0.jar
But I see this issue since 2.2.3 until 3.0.0?
Swagger declaration file content or url
api.yaml definition contains the "array of array" definition,
swagger: '2.0'
info:
title:
description:
version: "1.0.0"
host:
schemes:
http
https
basePath: /v1
produces:
application/json
paths:
/patients/{uuid}/forms:
get:
summary:
operationId:
description: |
tags:
parameters:
in: path
description: identifier uuid.
required: true
type: string
in: query
description: Start date-time for data.
required: false
type: string
format: dateTime
in: query
description: End date-time for data.
required: false
type: string
format: dateTime
responses:
200:
description: An array of updates
headers:
Access-Control-Allow-Origin:
type: string
default: "*"
schema:
type: array
items:
type: array
items:
$ref: '#/definitions/WaveformsUpdate'
Once the files are generated , I see missing imports for WaveformsUpdate and mvn clean install fails due to that.
Command line used for generation
Command to generate: java -jar libs/swagger-codegen-cli-3.0.0-rc0.jar generate -l java -i api.yaml -o target
Steps to reproduce
Create a yaml as below and generate code out of it.
type: array
items:
type: array
items:
$ref: '#/definitions/'
Related issues/PRs
I have see similar bugs in previous versions.
Suggest a fix/enhancement
Nothing for now. Please suggest if any
The text was updated successfully, but these errors were encountered: