[BUG][JAXRS-spec] useOneOfInterfaces option causes compilation error
Description
When using the useOneOfInterfaces option, the generated code does not compile.
Children classes are OK, but the generated parent is a class instead of an interface.
openapi-generator version
I've reproduces the issue with openapi-generator-maven-plugin : 7.0.1, 7.1.0 6.6.0
The option does not seem supported on previous releases.
OpenAPI declaration file content or url
OpenAPI spec :
https://gist.github.com/jerui1/da605832f67667e32a96f5c4d346640e
Sample maven project to reproduce :
Generation Details
mvn clean install
(I've tried using Java 17 or Java 21)
Reproduced on openapi-generator v7.2.0
The issue still occurs with openapi-generator v7.3.0
The same issue also occurs with jaxrs-resteasy generator (--additional-properties=useOneOfInterfaces=true). The expected interface for the oneOf schema is not generated and a class with the same name is generated in its place. However, the classes generated for the subschemas correctly implement the intended interface.
This has been open for 6 months without any resolution, is anyone maintaining this?
This is still an issue in v7.8.0
Likely root cause issue - https://github.com/OpenAPITools/openapi-generator/issues/14166
#14166 doesn't look like the reason for this issue. The useOneOfInterface option works for Spring Server gen as well as for the java clients: feign, google-api-client, resteasy, resttemplate, webclient, restclient, rest-assured, retrofit2, vertx, apache-httpclient Currently it doesn't work for the java clients: microprofile, jersey2, jersey3, native and okhttp-gson.
The issue is coming from the model.mustache file. The clients working don't override it or have the correct part. The clients not working are missing these part:
{{#vendorExtensions.x-is-one-of-interface}}{{>oneof_interface}}{{/vendorExtensions.x-is-one-of-interface}}
I'll provide a pr to fix this soon.
@Nicklas2751 , any chances to get this fix in the next release (7.13.0)?
@agaidaichuk I can't tell you if and when my PR (#20832) gets merged.
This issue is still present in v7.21.0 with jaxrs-spec.
I see recent activity in the related PR #20832. Any updates or ETA on when this might be addressed?
Luckily I found out that the issue has been fixed in the latest release 7.24.0, hooray! 😄
It's in the release notes (section "Java"): https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.24.0
I also managed to make the code example compile. All you have to do is to use the latest version of openapi-generator-maven-plugin (7.24.0 or higher) and add a dependency to the pom.xml which has become required sometime ago:
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>