gpt4 book ai didi

maven - 在 swagger maven 插件配置中包含信息对象

转载 作者:行者123 更新时间:2023-12-02 16:52:18 24 4
gpt4 key购买 nike

我在 swagger 输出 json 文件中包含信息对象时遇到问题。我正在使用 https://github.com/swagger-api/swagger-core 中的 swagger-maven-plugin 。这是我尝试过的...

  1. 我尝试在我的 pom.xml 中包含一个信息对象,如下所示...

            <plugin>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>2.0.9</version>
    <configuration>
    <outputFileName>openapi</outputFileName>
    <outputPath>${project.build.directory}/openapi-json</outputPath>
    <outputFormat>JSONANDYAML</outputFormat>
    <resourcePackages>
    <package>packageName</package>
    </resourcePackages>
    <info>
    <version>
    1.0
    </version>
    <title>
    Swagger Pet Sample App Config File
    </title>
    <description>
    This is a sample server Petstore server. You can find out more about Swagger.
    </description>
    <termsOfService>http://swagger.io/terms/
    </termsOfService>
    <license>
    <name>
    Apache2.0
    </name>
    <url>
    http://www.apache.org/licenses/LICENSE-2.0.html
    </url>
    </license>
    <contact>
    <email>
    <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ddbab8b2afbab89dbcb2b1f3beb2b0" rel="noreferrer noopener nofollow">[email protected]</a>
    </email>
    </contact>
    </info>
    <prettyPrint>TRUE</prettyPrint>
    </configuration>
    <executions>
    <execution>
    <phase>compile</phase>
    <goals>
    <goal>resolve</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>

我还尝试在我的路径中添加 openapi-configuration.yaml 文件。该文件看起来像这样。我从插件存储库自述文件页面复制了此文件,因此内容与上面的第一种方法不同。

    resourcePackages:
- packageName
prettyPrint: true
cacheTTL: 0
openAPI:
info:
version: '1.0'
title: Swagger Pet Sample App Config File
description: 'This is a sample server Petstore server. You can find out more
about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net,
#swagger](http://swagger.io/irc/). For this sample, you can use the api key
`special-key` to test the authorizat ion filters.'
termsOfService: http://swagger.io/terms/
contact:
email: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2c4d5c4558494d416c5f5b4d4b4b495e024543" rel="noreferrer noopener nofollow">[email protected]</a>
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html

这两种方法都不起作用。

我错过了什么?干杯。

最佳答案


更新我的工作如下......在我的 pom.xml 中...

            <plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.0.9</version>
<configuration>
<outputFileName>openapi</outputFileName>
<outputPath>${project.build.directory}/openapi-json</outputPath>
<outputFormat>JSONANDYAML</outputFormat>
<resourcePackages>
<package>packageName.services</package>
</resourcePackages>
<configurationFilePath>${project.basedir}/openapi.yaml</configurationFilePath>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>

然后在单独的配置 YAML 文件中...

  openAPI:
info:
version: '1.0'
title: API Documentation
description: 'This is documentation for the Foosite API. You can find out more about FooSite at FooSite.org.'
termsOfService: http://foosite.org/terms/
license:
name: Apache2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
contact:
email: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c1b19130e1b193c1d1310521f1311" rel="noreferrer noopener nofollow">[email protected]</a>
prettyPrint: true

关于maven - 在 swagger maven 插件配置中包含信息对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58000340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com