带有spring-boot-starter-data-mongodb的springdoc-openapi

问题描述 投票:1回答:1

使用mongoDb启动新的spring-boot应用程序(2.2.1.RELEASE)。

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>

并创建一些api文档,我添加

<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-ui</artifactId>
  <version>1.1.49</version>
</dependency>

由于我依靠spring来处理REST端点的生成,因此我创建了这个简单的存储库。

@RepositoryRestResource(collectionResourceRel = "profile", path = "profile")
public interface ProfileRepository extends MongoRepository<Profile, String> {

  List<Profile> findByLastname(@Param("n") String lastname);
  List<Profile> findByFirstname(@Param("n") String firstname);
  List<Profile> findByEmail(@Param("e") String email);

}

所以我没有@RestController类。我试图向ProfileRepository中的方法添加一些io.swagger.v3.oas.annotations,但未生成任何内容。

@Operation(summary = "Find Profile by first name", description = "Find Profile by first name")
List<Profile> findByLastname(@Param("n") String lastname);

关闭http://localhost:8080/v3/api-docs/的结果

{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"paths": {},
"components": {}
}

任何人都可以给我一些有关如何生成api文档的提示吗?

java spring-boot swagger-ui spring-data-mongodb
1个回答
0
投票

根据此问题:https://github.com/springdoc/springdoc-openapi/issues/282,由于[],不可能从spring-boot-starter-data-rest生成OpenAPI文档。>

spring-data-rest实体端点在运行时动态生成[...]

在上述GitHub问题上引自用户“ bnasslahsen”。

© www.soinside.com 2019 - 2024. All rights reserved.