openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][JAVA] Unnecessary Jackson imports added to oneOf interface when non-Jackson library is used

Open DavidGrath opened this issue 7 months ago • 1 comments

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

DavidGrath avatar Jun 10 '25 12:06 DavidGrath

https://github.com/OpenAPITools/openapi-generator/pull/21405 @martin-mfg

DavidGrath avatar Jun 10 '25 12:06 DavidGrath