问题描述
我正在通过 Open API Maven 插件生成模型类,我需要在我的业务逻辑中使用它。 api由其他团队生成并提供给我们。它有很多模型类规范,但我只需要从 api.yaml 模板生成 3 个模型类
如何实现?
插件配置
<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>
解决方法
根据 github readme of the openapi-generator-maven-plugin,有一个名为 modelsToGenerate
的配置选项,它完全符合您的要求:
要生成的模型的逗号分隔列表。所有型号均为默认。