Reputation: 13
I am using Open API Generator with Java Maven Plugin
When I build the project, it generates two methods, one with the annotation and the other for us to override. Why can't it be a single one instead? Is anything configured wrong?
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>club.allin.api</apiPackage>
<modelPackage>club.allin.models</modelPackage>
<skipValidateSpec>false</skipValidateSpec>
<strictSpec>true</strictSpec>
<generateApiDocumentation>true</generateApiDocumentation>
<removeOperationIdPrefix>true</removeOperationIdPrefix>
<configOptions>
<useTags>true</useTags>
<delegatePattern>true</delegatePattern>
<interfaceOnly>true</interfaceOnly>
<removeOperationIdPrefix>true</removeOperationIdPrefix>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
It generates something like that
@GetMapping
default ResponseEntity<ResponseObject> _getSpendings(){
return getSpendings();
}
//Override this method
default ResponseEntity<ResponseObject> getSpendings(){
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Why does it generate two methods? Can I configure to be only one?
Upvotes: 1
Views: 2436
Reputation: 46
You are setting <delegatePattern>true</delegatePattern>
, just set it to false or remove it (default value is false) if you don't need it and you will get a single method. I encountered troubles with delegate pattern when I tried to trigger an aspect for controller method and it did the trick as well.
Upvotes: 3