Closed
Description
Describe the bug
When document spring data rest repositories with @RepositoryRestResource
, methods declared by CrudRepository or PagingAndSortingRepository are ignored by springdoc. Custom methods works fine.
To Reproduce
Declare RepositoryRestResource repository, and annotate method inherit from PagingAndSourtingRepository, for example, findById with @Operation
or @ApiResponses
:
@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
@Operation(summary = "find by id")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "successful operation"),
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
@ApiResponse(responseCode = "404", description = "Contact not found"),
@ApiResponse(responseCode = "405", description = "Validation exception") }
)
@RestResource
Optional<Person> findById(Long id);
Expected behavior
When call to /v3/api-docs
, paths['/peopleme/{id}'].get.description
must be description declared by @Operation
annotation.
@Test
void given_repositoryRestResource_when_getApiDocs_then_findByIdDocumentationOk() {
// @formatter:off
given()
.when()
.get("/v3/api-docs")
.then()
.status(HttpStatus.OK)
.rootPath("paths['/peopleme/{id}']")
.body("get.description", equalTo("find by id"));
// @formatter:on
}
You can check issue in:
https://github.com/migueltercero/springdoc-issue