swagger-api / swagger-api/swagger-codegen
Java: 0 Warnings for generated code
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Currently the generated Java files reference imports that are not used, resulting in compiler warnings.
e.g. for Java jaxrs-cxf Models:
import java.io.File; // Warning e.g. in Models
import io.swagger.model.HelloModel;
import java.io.InputStream; // Warning e.g. in Models
import java.io.OutputStream; // Warning e.g. in Models
import java.util.List; // Warning e.g. in Models
import java.util.Map; // Warning e.g. in Models
import javax.ws.rs.*;
import javax.ws.rs.core.Response; // Warning e.g. in Models
Swagger-codegen version
master
Suggest a fix/enhancement
The quick fix would be to use more generalized imports like :
import java.io.*;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
Alternatively or supplementing this, we could use a routine to automatically cleanup the unused imports after generating the code?
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
Start by locating the Java jaxrs-cxf templates responsible for generated Models and inspecting how their imports are assembled. Compare the generated imports with the types each file uses, then determine how to verify the result through generation and Java compilation checks. Done means generated Java files no longer produce warnings for unused imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100