OpenAPITools / OpenAPITools/openapi-generator
[BUG] [spring] [server] 5.0.1 unused imports in generated interfaces
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generated API interfaces contain the following unused imports, which introduce unnecessary dependencies:
import org.springframework.data.domain.Pageable;import springfox.documentation.annotations.ApiIgnore;
openapi-generator version
5.0.1
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
file "springboot-options.json"
{
"basePackage":"io.swagger",
"configPackage":"io.swagger.config",
"parentGroupId":"org.springframework.boot",
"parentArtifactId":"spring-boot-starter-parent",
"parentVersion":"2.4.3",
"serverPort":9230,
"dateLibrary":"java8"
}
command line
java -jar ./openapi-generator-cli-5.0.1.jar generate -g spring -i petstore.yaml -o server\springboot\openapi -c springboot-options.json
Example: imports within generated file UserApi
package org.openapitools.api;
import java.util.List;
import org.openapitools.model.User;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
Related issues/PRs
Suggest a fix
Remove imports of springfox.documentation.annotations.ApiIgnore and data.domain.Pageable within the api interfaces, as they are not used and not needed.
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 Spring server generation with petstore.yaml, springboot-options.json, and the shown CLI command, then inspect the generator template responsible for the generated UserApi interface. Confirm that the generated interface no longer includes the two reported unused imports and that the generated output remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100