Microprofile在生成时生成Open-Api文件

时间:2019-10-10 06:54:26

标签: java maven swagger openapi microprofile

在使用Eclipse Microprofile之前,我们已经通过io.openapitools.swagger:swagger-maven-plugin生成了open-api文件。 此插件依赖于io.swagger.core.v3:swagger-annotations maven依赖项。

Eclipse Microprofile虽然具有不同的依赖关系,但这似乎不足以满足openapitools插件的要求,因此所生成的open-api文件不包含任何描述以及注释内提供的其他数据。

您知道一种使用微配置文件依赖项生成开放式API定义文件的方法吗?

以下是openapitools swagger插件的配置。

<plugin>
<groupId>io.openapitools.swagger</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
    <execution>
        <id>default</id>
        <phase>verify</phase>
        <goals>
            <goal>generate</goal>
        </goals>
        <inherited>true</inherited>
        <configuration>
            <useResourcePackagesChildren>true</useResourcePackagesChildren>
            <outputDirectory>${project.build.directory}/open-api/</outputDirectory>
            <outputFormats>JSON,YAML</outputFormats>
            <prettyPrint>false</prettyPrint>

            <resourcePackages>
                <resourcePackage>...</resourcePackage>
            </resourcePackages>
            <outputFilename>...</outputFilename>
        </configuration>
    </execution>
</executions>

1 个答案:

答案 0 :(得分:0)

到目前为止,我唯一发现的是Apache Geronimo项目创建的插件:Geronimo OpenAPI Maven plugin。他们在GitHub页面上的示例显示了如何使用它。

<plugin>
  <groupId>org.apache.geronimo</groupId>
  <artifactId>geronimo-openapi-maven-plugin</artifactId>
  <version>${openapi.version}</version>
  <executions>
    <execution>
      <id>generate-openapi.json</id>
      <goals>
        <goal>openapi.json</goal>
      </goals>
      <configuration>
        <application>com.test.MyApp</application>
        <endpointClasses>
          <endpointClass>com.test.SomeEndpoint</endpointClass>
          <endpointClass>com.test.SomeOtherEndpoint</endpointClass>
        </endpointClasses>
        <info>
          <version>1</version>
          <title>My Title</title>
          <description>Bla Bla</description>
        </info>
      </configuration>
    </execution>
  </executions>
</plugin>

不幸的是,documentation很薄。根据依赖关系列表,它似乎还支持YAML格式。