Skip to content
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] Nested generics causes missing imports #5885

Closed
markebbers opened this issue Jun 20, 2017 · 3 comments
Closed

[JAVA] Nested generics causes missing imports #5885

markebbers opened this issue Jun 20, 2017 · 3 comments

Comments

@markebbers
Copy link

Description

If a method is using nested generics in an method argument, like List<List>, the generated Api class is missing an import for this model class. In this case 'MissingObject'.

Swagger-codegen version

Tested with 2.2.1 and 2.2.2.

Swagger declaration file content or url

proof of concept:
https://gist.github.com/markebbers/7e9fcecdfe1b5c15604618519b5a5ecc

suspect:

"parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/definitions/MissingObject"
                }
              }
            }
          }
        ]
Command line used for generation

Used the swagger-codegen-maven-plugin 2.2.1 and 2.2.2.

[DEBUG] Configuring mojo 'io.swagger:swagger-codegen-maven-plugin:2.2.2:generate' with basic configurator -->
[DEBUG]   (f) addCompileSourceRoot = true
[DEBUG]   (f) apiPackage = poc.api
[DEBUG]   (f) configOptions = {dateLibrary=joda, library=jersey2}
[DEBUG]   (f) inputSpec = /home/x/Work/prototype/pocswaggergeneric/src/main/resources/swagger.json
[DEBUG]   (f) language = java
[DEBUG]   (f) modelPackage = poc.model
[DEBUG]   (f) output = /home/x/Work/prototype/pocswaggergeneric/target/generated-sources/openapi
[DEBUG]   (f) project = MavenProject: poc:api:1.0-SNAPSHOT @ /home/x/Work/prototype/pocswaggergeneric/pom.xml
[DEBUG]   (f) verbose = false
[DEBUG] -- end configuration --
[INFO] reading from /home/x/Work/prototype/pocswaggergeneric/src/main/resources/swagger.json
Steps to reproduce

Generate and compile the code.

Related issues
Suggest a Fix

Not yet found. But it looks likes the nested array of arrays of ObjectMissing objects is the cause of the problem.

@wing328
Copy link
Contributor

wing328 commented Jun 21, 2017

@markebbers thanks for reporting the issue with a spec to easily reproduce the issue, which helps a lot.

I'm looking into it...

@wing328
Copy link
Contributor

wing328 commented Jun 21, 2017

It should be fixed by #5891

I did a test with the spec you provided and mvn test does not report any issue.

@wing328
Copy link
Contributor

wing328 commented Jun 21, 2017

@markebbers PR merged into master. Please pull the latest master to give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants