我在 Spring Boot 中有一个带有 Spring Data Rest 的应用程序,我正在尝试使用 swagger-maven-plugin 使用 Swagger 生成文档。Controller 文档的生成没有问题,但存储库没有。
我在 pom.xml 中配置了以下形式的 swagger-maven-plugin:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.6</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>true</springmvc>
<locations>
<location>com.abelendo.repository</location>
<location>com.abelendo.controller</location>
</locations>
<schemes>http</schemes>
<host>localhost:8080</host>
<basePath>/</basePath>
<info>
<title>Swagger Maven Plugin Spring Boot for cars</title>
<version>v1</version>
<description>Working sample of Spring Boot for cars annotations</description>
<termsOfService>
http://www.github.com
</termsOfService>
<contact>
<email>abelendo@email.com</email>
<name>Abelendo Cars</name>
<url>http</url>
</contact>
<license>
<url>http://www.license.com</url>
<name>License name</name>
</license>
</info>
<!-- Support classpath or file absolute path here.
1) classpath e.g: "classpath:/markdown.hbs", "classpath:/templates/hello.html"
2) file e.g: "${basedir}/src/main/resources/markdown.hbs",
"${basedir}/src/main/resources/template/hello.html" -->
<templatePath>${basedir}/templates/strapdown.html.hbs</templatePath>
<outputPath>${basedir}/generated/document.html</outputPath>
<outputFormats>yaml</outputFormats>
<swaggerApiReader>com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader</swaggerApiReader>
<swaggerDirectory>generated/swagger-ui</swaggerDirectory>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
我的汽车存储库:
@Api(tags = "CarsRepo")
@RepositoryRestResource(path = "cars")
public interface CarRepository extends CrudRepository<Car, Long> {
<S extends Car> S save(@Valid S cars);
}
是否可以使用 swagger-maven-plugin 生成存储库文档?