9

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>

2 Answers 2

12

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Also it's better to set <generateApis>false</generateApis> if you don't need any controllers
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.