如何解决Open API Maven Plugin - 只生成特定的 API 模型类
我正在通过 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
的配置选项,它完全符合您的要求:
要生成的模型的逗号分隔列表。所有型号均为默认。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。