1

I'm using the Swagger v3 annotations to document my controller routes, e.g.:

@OpenAPIDefinition(info = 
    @Info(title = "swagger-spring", 
          description = "testing swagger in a spring environment", 
          version = "0.1", 
          contact = @Contact(name = "Thilo Schwarz", 
                             email = "osp (at) domain.codes", 
                             url = "https://domain.codes")))
public class Controller {

    @Operation(summary = "Says hello.")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200",
                         description = "Just returns 'hello'.",
                         content = @Content(mediaType = "text/plain",
                                            examples = {@ExampleObject(value = "HELLO!") })) })
    public String hello() {
        return "HELLO!";
    }
}

In my pom, I'm using the following plugin settings:

            <plugin>
                <groupId>io.openapitools.swagger</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>2.1.6</version>
                <configuration>
                    <resourcePackages>
                        <resourcePackage>codes.thischwa.swagger</resourcePackage>
                    </resourcePackages>
                    <outputDirectory>${project.build.directory}/</outputDirectory>
                    <outputFilename>openapi</outputFilename>
                    <outputFormats>JSON,YAML</outputFormats>
                    <prettyPrint>true</prettyPrint>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-openapi</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-jaxrs2</artifactId>
                        <version>2.2.2</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.ws.rs</groupId>
                        <artifactId>javax.ws.rs-api</artifactId>
                        <version>2.1</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.servlet</groupId>
                        <artifactId>javax.servlet-api</artifactId>
                        <version>3.1.0</version>
                    </dependency>
                </dependencies>
            </plugin>

If I'm calling mvn integration-test, I get the following error:

[ERROR] Failed to execute goal io.openapitools.swagger:swagger-maven-plugin:2.1.6:generate (generate-openapi) on project swagger-spring: Execution generate-openapi of goal io.openapitools.swagger:swagger-maven-plugin:2.1.6:generate failed: Scanner SubTypesScanner was not configured -> [Help 1]

I guess, I missed some configuration settings. But which one? I couldn't find any hints at the developers website.

Update:

Possible bug found: https://github.com/openapi-tools/swagger-maven-plugin/issues/96

Thilo Schwarz
  • 640
  • 5
  • 24
  • Did you manage solve this? I am running into same issue. – Arti Feb 23 '23 at 13:24
  • @Arti Sadly not. My project I'm working on based on spring boot, so my workaround was using springdoc-openapi. But I don't like it because I don't need this stuff at runtime. That's why I have to disable it explicitly on the production system. – Thilo Schwarz Feb 23 '23 at 13:45

0 Answers0