openmetadata 的client 是基于swagger maven 代码生成扩展生成的,client 层核心是包装了一些认证处理的
插件配置
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.16</version>
<dependencies>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>/Users/dalong/mylearning/open-metadata/newop/openmetadata-service/target/classes/assets/swagger.yaml</inputSpec>
<language>java</language>
<library>feign</library>
<generateApiTests>true</generateApiTests>
<generateModelTests>true</generateModelTests>
<apiPackage>org.openmetadata.client.api</apiPackage>
<modelPackage>org.openmetadata.client.model</modelPackage>
<configOptions>
<generateForOpenFeign>true</generateForOpenFeign>
<sourceFolder>src/main/java/</sourceFolder>
</configOptions>
<output>${project.build.directory}/generated-sources/swagger
</output>
</configuration>
</execution>
</executions>
</plugin>生成的client 结构
- 参考图
基本都是swagger 代码生成器的结构
不同client 的处理,每个rest api 接口会有不同的client 同时也是swagger api 的结构
说明
以上实际上有一些问题,就是官方的使用feign 版本有点地,同时时间处理上依赖了com.fasterxml.jackson.datatype.threetenbp
参考资料
https://github.com/OpenFeign/feign
https://github.com/swagger-api/swagger-codegen/tree/3.0.0/modules/swagger-codegen-maven-plugin
https://github.com/swagger-api/swagger-codegen/tree/3.0.0/modules/swagger-codegen-maven-plugin/examples
https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-clients/openmetadata-java-client/pom.xml