I want to use springdoc-openapi-ui in a generated service with swagger-codegen-maven-plugin, but the API generated uses wrong package, it uses io.swagger.annotations instead of io.swagger.v3.oas.annotations
What can I do for that?
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>
I had same issue which lead me to read the docs: https://openapi-generator.tech/docs/plugins
By adding below line in my build.gradle fixed the issue:
implementation group: 'io.swagger.parser.v3', name: 'swagger-parser', version: '2.0.20'
Hope it helps someone...
You should test a newer version of swagger-codegen-maven-plugin. I had the same issue and version 3.0.27 fixed it for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.