【发布时间】:2019-07-17 16:27:14
【问题描述】:
我正在开发一个使用 swagger 为我的 API 生成文档的 Spring Boot 应用程序,我正在使用 Spring data rest 来生成 Api,但是当我运行该应用程序时,我收到了 swagger 消息:没有定义操作符合规范!
这是我的 Api 代码:
@Api(tags = "projets")
@RepositoryRestResource(collectionResourceRel = "projets", path = "projets")
public interface IProjectRepository extends JpaRepository<Project, Long> {
}
这是我的配置文件:
@Configuration
@EnableSwagger2
public class QfactoryConfiguration {
@Bean
public Docket getDocketInstance() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.title("Spring Boot project")
.description("Spring Boot bootstrap project")
.version("0.1")
.license("Unlicense")
.build())
.select()
.apis(RequestHandlerSelectors.basePackage("com.errabi.qfactory.repositories"))
.paths(PathSelectors.any())
.build();
}
}
这是我正在使用的依赖项:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
我问的是 Swagger 是否能够为 Spring data rest 生成的 Api 生成文档,或者我应该使用带有注释的 @RestController @Api,@ApiOperation
我使用的是 Spring Boot 版本:2.1.3.RELEASE
【问题讨论】:
标签: java spring-boot swagger spring-data-rest springfox