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