Search code examples
javamavenmaven-pluginopenapiopenapi-generator-maven-plugin

Generate only POJOs from OpenAPI definition


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>

Solution

  • 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.