【问题标题】:Microprofile generate Open-Api File on buildMicroprofile 在构建时生成 Open-Api 文件
【发布时间】:2019-10-10 06:54:26
【问题描述】:

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

Eclipse Microprofile 虽然带有一个不同的依赖项,这对于 openapitools 插件似乎不够用,因此生成的 open-api 文件不包含注释中提供的任何描述和其他数据。

您知道使用微配置文件依赖项生成 open-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>

【问题讨论】:

    标签: java maven swagger openapi microprofile


    【解决方案1】:

    到目前为止,我发现的唯一东西是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 格式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-22
      • 2020-03-25
      • 1970-01-01
      • 2017-12-31
      • 1970-01-01
      • 2010-11-30
      • 2023-02-07
      • 1970-01-01
      相关资源
      最近更新 更多