简体   繁体   中英

Open API Maven Plugin - Generate only specifc API model classes

I am working on generation of model classes by Open API Maven plugin which I need to use in my business logic. The api is generated by other team and given to us. It has lot of model classes specification but I need only generation of 3 model classes from the api.yaml template

How this can be achieved?

The plugin configuration

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>generate-java-client</id>
            <configuration>
                <inputSpec>
                    ${project.build.directory}/../../../../../../../../../component/service/app/src/main/resources/api/v1/api-v1.yaml
                </inputSpec>
                **<modelPackage>com.example.editing.model</modelPackage>**
                <generateSupportingFiles>false</generateSupportingFiles>
                <generateApis>false</generateApis>
                <generateApiTests>false</generateApiTests>
                <generateModelTests>false</generateModelTests>
            </configuration>
        </execution>
    </executions>
</plugin>

According to the github readme of the openapi-generator-maven-plugin , there is a configuration option called modelsToGenerate which does exactly what you want:

A comma separated list of models to generate. All models is the default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM