swaggeropenapi-generator-maven-plugin

How to fix "package io.swagger.annotations does not exist" for openapi-generator-maven-plugin?


I use openapi-generator-maven-plugin:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>6.3.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/src/main/resources/openapi.json</inputSpec>
                <generatorName>jaxrs-spec</generatorName>
                <configOptions>
                    <sourceFolder>src/gen/java/main</sourceFolder>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

And I use swagger-annotations:

<dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-annotations</artifactId>
    <version>2.2.7</version>
</dependency>

But after generation I have got: package io.swagger.annotations does not exist. How to fix it?


Solution

  • I have solved the problem add:

    <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-annotations</artifactId>
        <version>1.6.9</version>
    </dependency>
    

    Version 2.2.7 does not contain a io.swagger.annotations.Api annotation.