swagger-api / swagger-api/swagger-codegen
SpringCodegen not importing java.util.List
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
When using the swagger-codegen-cli and the Spring language, java.util.List is not being imported and compilation fails.
Description
[ERROR] /Users/davidnewcomb/Development/git/x/v1client/src/main/java/com/example/api/MyManagementApi.java:[64,15] cannot find symbol
[ERROR] symbol: class List
[ERROR] location: class com.example.api.MyManagementApi
Swagger-codegen version
3.0.4-SNAPSHOT (branch 3.0.0 HEAD)
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli.jar generate \
-i liveres-1.0.0-rc2.json \
-l java \
-c resttemplate-config.json \
-o v1client
resttemplate-config.json
{
"modelPackage" : "com.example.model",
"apiPackage" : "com.example.api",
"invokerPackage" : "com.example.v1.client",
"groupId" : "com.example.v1",
"artifactId" : "v1client",
"fullJavaUtil" : true,
"dateLibrary" : "java8",
"library" : "resttemplate"
}
Steps to reproduce
After running the generator:
cd v1client
mvn clean install
Compilation fails because file src/main/java/com/example/api/MyManagementApi.java contains lines like:
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
but there is no import statement.
Related issues/PRs
Very similar to #7432
Suggest a fix/enhancement
Add import java.util.List to the top.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided swagger-codegen-cli command and inspect the generated src/main/java/com/example/api/MyManagementApi.java. Trace the Spring generator output responsible for its imports, then run mvn clean install in the generated v1client project; done means the List type is imported and compilation succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100