openapi-generator-maven-plugin(版本 6.3.0)在 Spring-Boot 3 应用程序中配置如下:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/openApi.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>com.company.api.v1</apiPackage>
<modelPackage>com.company.model.v1</modelPackage>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<delegatePattern>true</delegatePattern>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
在 Swagger/OpenAPI Yaml 文件中仅配置了一个端点:
paths:
/table:
get:
summary: get all trains
operationId: trainsList
tags:
- zuege
这里的问题出在 Swagger-Ui 中;端点重复:
当我删除 yaml 中的标签时,只有第一个端点可见,但实际上这是带有生成描述的丑陋端点。当我配置它时<useTags>true</useTags>
(参见配置 https://openapi-generator.tech/docs/generators/spring/)两个端点仍然存在,但都有名称zuege
.
知道如何将其减少到只有一个端点但考虑标签吗?
当我添加全局标签描述如下:
tags:
- name: zuege
description: "Zuege details"
和...一起<useTags>true</useTags
它看起来如下:
所以还是重复的。
openapi-generator-maven-plugin 6.3.0 似乎存在问题,因为它从 yaml 文件转换标签名称,例如
tags:
- name: zuege
到生成的代码中稍微偏离的注释标记中,即:
@Tag(name = "Zuege", description = "Zuege details")
public interface ZuegeApi {
}
因此,当您将 yaml 文件中的标记更改为相同样式(第一个字符始终为大写)时,问题就消失了:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)