Reputation: 2507
I have written an web service definition as an OpenAPI document. The openapi-generator-maven-plugin I'm using always generates a whole project with poms and gradle build scripts, but I only need the pojos and maybe the API client to be generated. It should work equally to JaxB or JaxWS code generators.
So is there a way to tell the plugin to generate the Java-Code only? Maybe there is another plugin which does the job?
Here is my configuration:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/my-api.yaml</inputSpec>
<modelPackage>com.my.path.to.api</modelPackage>
<generatorName>java</generatorName>
<generateApis>false</generateApis>
<generateModels>true</generateModels>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<library>vertx</library>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 9
Views: 27877
Reputation: 2594
In your model project A, allow only model generation.
<generateApis>false</generateApis>
<configOptions>
<modelPackage>${default.package.model}</modelPackage>
</configOptions>
In your corresponding client/server project B, disable model generation and point the model package name to project A
<generateModels>false</generateModels>
<configOptions>
<modelPackage>${default.package.model}</modelPackage>
</configOptions>
This is useful when you want to generate multiple server definitions based on different frameworks but want to use the same model underneath.
Upvotes: 1
Reputation: 138
From the docs: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin
The property you are looking for is:
generateSupportingFiles
Set it to false if you do not want the additional pom.xml, etc project files generated as well.
Upvotes: 10