簡體   English   中英

帶有 springdoc-openapi-ui 的 swagger-codegen-maven-plugin

[英]swagger-codegen-maven-plugin with springdoc-openapi-ui

我想在帶有 swagger-codegen-maven-plugin 的生成服務中使用 springdoc-openapi-ui,但是生成的 API 使用錯誤的 package,它使用 io.swagger.annotations 而不是 io.88324151914

我能為此做什么?

import io.swagger.annotations.*;
import ...
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-10-07T13:17:04.413+02:00[Europe/Madrid]")
@Api(value = "randomPet", description = "the randomPet API")
public interface RandomPetApi {
...
}
<plugin>
                    <groupId>io.swagger.codegen.v3</groupId>
                    <artifactId>swagger-codegen-maven-plugin</artifactId>
                    <version>3.0.11</version>
                    <executions>
                        <execution>
                            <id>generate-swagger-spring-boot</id>
                            <phase>none</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <inputSpec>${swagger-codegen.api.spec}</inputSpec>
                                <language>spring</language>
                                <apiPackage>${project.groupId}.web.api</apiPackage>
                                <modelPackage>${project.groupId}.web.api.model</modelPackage>
                                <generateApiDocumentation>false</generateApiDocumentation>
                                <generateModelTests>false</generateModelTests>
                                <generateModelDocumentation>false</generateModelDocumentation>
                                <additionalProperties>
                                    <java8>true</java8>
                                    <additionalProperty>jackson=true</additionalProperty>
                                </additionalProperties>
                                <library>jersey2</library>
                                <addCompileSourceRoot>true</addCompileSourceRoot>
                                <generateApiTests>false</generateApiTests>
                                <generateModelTests>false</generateModelTests>
                                <configOptions>
                                    <sourceFolder>.</sourceFolder>
                                    <useBeanValidation>true</useBeanValidation>
                                    <performBeanValidation>true</performBeanValidation>
                                    <dateLibrary>java8</dateLibrary>
                                    <delegatePattern>true</delegatePattern>
                                </configOptions>
                            </configuration>
                        </execution>
                    </executions>
</plugin>

我有同樣的問題導致我閱讀文檔: https://openapi-generator.tech/docs/plugins

通過在我的 build.gradle 中添加以下行來解決問題:

    implementation group: 'io.swagger.parser.v3', name: 'swagger-parser', version: '2.0.20'

希望它可以幫助某人...

您應該測試更新版本的 swagger-codegen-maven-plugin。 我遇到了同樣的問題,3.0.27 版為我修復了它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM