I have an OpenAPI 3.0 file that specifies two REST resources with operations, let's say:
openapi: 3.0.0
[...]
paths:
/a:
post:
[...]
/b
post:
[...]
Then I use the openapi-generator-maven-plugin like:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.1.2</version>
<configuration>
[...]
<configOptions>
<interfaceOnly>true</interfaceOnly>
[...]
</configOptions>
</configuration>
</plugin>
To generate Java interfaces, giving me:
public interface AApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
default ResponseEntity<String> postA([...]) { [...] }
}
public interface BApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
default ResponseEntity<String> postB([...]) { [...] }
}
In the end, I would like to write a single class that implements both interfaces:
class TheController implements AApi, BApi { [...] }
However, the getRequest() method gets in the way, because Java is unable to inherit two default implementations with identical names.
Is there a way to suppress generating this method? (Or some other means to enable implementing both interfaces, that I haven't thought of?)
I know this question is already answered, but I also had this issue and found a different solution. You can also add this in the configOptions section:
<configOptions>
<skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
It does have the 'side effect' that you no longer have default implementations.
See also documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With