我想在带有swagger-codegen-maven-plugin的生成的服务中使用springdoc-openapi-ui,但是生成的API使用了错误的包,它使用io.swagger.annotations而不是io.swagger.v3.oas。注释
我该怎么办?
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>
答案 0 :(得分:1)
我遇到了同样的问题,导致我阅读了以下文档:https://openapi-generator.tech/docs/plugins
通过在我的build.gradle中添加以下行来解决此问题:
implementation group: 'io.swagger.parser.v3', name: 'swagger-parser', version: '2.0.20'
希望它可以帮助某人...