openapi-generator
openapi-generator copied to clipboard
[BUG][JAVA] Unnecessary Jackson imports added to oneOf interface when non-Jackson library is used
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator?
- [x] 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
The generator adds unnecessary Jackson imports to a oneOf interface when using retrofit2 and gson, which causes a build error because of the non-existent package
openapi-generator version
7.13.0
OpenAPI declaration file content or url
Reusing oneOf.yaml
Generation Details
Config:
library: 'retrofit2'
useOneOfInterfaces: true
Command:
java -jar openapi-generator-cli.jar generate -g java -i oneOf.yaml -c config.yaml -o out
Steps to reproduce
./gradlew.bat build
Expected output
// Other imports
// No Jackson Imports
public interface Fruit {
}
Actual output
// Other imports
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
public interface Fruit {
}
Related issues/PRs
Suggest a fix
PR Incoming
https://github.com/OpenAPITools/openapi-generator/pull/21405 @martin-mfg