Open mkytkajr65 opened 5 years ago
I'm having this exact same issue. I'm using the swagger-codegen-maven-plugin.
The WebMvcLinksHandler uses "Link" in the method signatures, but does not import it.
The objects that are at the package root are imported, but "Link" is under package-root.resource... and is not imported.
When I manually add the import for Link... everything compiles fine.
Just ran across the same issue.
What is the issue: No import statement added in the generated file for class "ReservationWindow"
swagger-codegen-plugin
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.4.24</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/vmware-cloud-on-aws-general.json</inputSpec>
<language>java</language>
<output>${project.build.directory}/generated-sources</output>
<apiPackage>com.stg.vmc.handler</apiPackage>
<modelPackage>com.stg.vmc.model</modelPackage>
<invokerPackage>com.stg.vmc.handler</invokerPackage>
</configuration>
</execution>
</executions>
</plugin>
Snippet from swagger file that is causing the issue
"200": {
"description": "Successful response",
"schema": {
"additionalProperties": {
"items": {
"$ref": "#/definitions/ReservationWindow"
},
"type": "array"
},
"type": "object"
}
}
Description
I have a return type for a 200 response code that is a nested "additionalProperties" field that generates to
Map<String, Map<String, Link>>
. Within the generated SDK code, the generator omits the import for the Link class. It omits it for both the API class (WebMvcLinksHandlerApi.java) as well as the associated test class (WebMvcLinksHandlerApiTest.java). As a result, the Java code does not compile without manually adding the import.Swagger-codegen version
3.0.10
I have also tried other version and it failed in those too.
Swagger declaration file content or url
Nested additional Properties
Nested additional Properties with more JSON context
Command line used for generation
swagger-codegen generate -i swagger.json -l java -c config.json -o tmp/
Steps to reproduce
Generate and compile via mvn clean install
Related issues/PRs
Maybe https://github.com/swagger-api/swagger-codegen/issues/3140 ?
Suggest a fix/enhancement
N/A