I want to generate an OpenApi 3.0 definition, at compile time, using maven plugin, from existing Spring (note: NOT Boot) app sources.
I have set up io.swagger.v3.oas.annotations in controller classes like so:
package com.acme.rest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "Dummy Controller", description = "Dummy controller.")
@RestController
@RequestMapping("/api/v1/dummy")
public class DummyController {
@Operation(summary = "dummy(). Does litrally nothing.")
@RequestMapping(value = "/", method = RequestMethod.GET)
public String doStuff() {
return "dummy";
}
}
and tried the swagger-maven-plugin
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<outputPath>${project.build.directory}/swagger-def</outputPath>
<resourcePackages>com.acme</resourcePackages>
<prettyPrint>true</prettyPrint>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
however I get nothing except openapi version.
mvn clean compile, produces:
{
"openapi" : "3.0.1"
}
I dug a bit through the implementation and it seems like there is no io.swagger.v3.oas.integration.api.OpenApiReader and/or io.swagger.v3.oas.integration.api.OpenApiScanner implementation to actually pick up the relevant annotations and parse them. I draw this conclusion from the fact that if I add custom implementation of them as suggested in the docs I can sources generated.
<scannerClass>com.acme.util.SwaggerOpenApiScanner</scannerClass>
<readerClass>com.acme.util.SwaggerOpenApiReader</readerClass>
I just dont understand why out of the box SWAGGER plugin does not parse SWAGGER annotations despite both of them are from the very same group io.swagger.core.v3?
What am I missing something? Can you recommend some alternative plugin to do this job?