swagger-api / swagger-api/swagger-codegen

jaxrs codegen generates unused imports

Open
#4,528 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: General help wanted Server: Java
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

jaxrs codegen generates the following unused imports in my ApiService class:
import package.generated.api.
;
import package.generated.data.*;
import package.generated.data.GeneratedModeal;
import package.generated.api.NotFoundException;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import java.util.List;
import java.io.InputStream;
Really annoying is the dependency to FormDataContentDisposition with forces me to add an unused dependency to my project.

Swagger-codegen version

2.2.0

Command line used for generation

java -Dmodels -Dapis -DapiTests=false -jar swagger-codegen-cli-2.2.0.jar generate -i xxx.yaml -l jaxrs -c config.json

Config

{
"sourceFolder" : "src/main/java",
"implFolder" : "src/main/java",
"modelPackage" : "package.generated.data",
"apiPackage" : "package.generated.api",
"invokerPackage" : "package.invoker",
"library" : "jersey2"
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the JAX-RS generation with swagger-codegen-cli 2.2.0, the supplied command, config, and a matching Swagger definition. Inspect the JAX-RS Jersey2 generation entry point and compare the generated ApiService imports; done means unused imports, especially FormDataContentDisposition and the listed package imports, are no longer emitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.