-
-
Notifications
You must be signed in to change notification settings - Fork 534
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When disabling all single entity access methods and only allowing whole collection endpoints like in the repository bellow. Spring doc will still show a GET method endpoint for a single entity via an ID. The corresponding endpoint will return 405 (Method not allowed) because it is disabled.
generated yaml:
/notifications:
get:
description: get-notification
......
/notifications/{id}:
get:
description: get-notification
......
To Reproduce
Using springdoc 1.5.4
@RepositoryRestResource
public interface NotificationRepository extends PagingAndSortingRepository<Notification, Long> {
//This should be the only available endpoint
@Override
@RestResource
List<Notification> findAll();
@Override
@RestResource(exported = false)
Optional<Notification> findById(Long aLong);
@Override
@RestResource(exported = false)
<S extends Notification> S save(S entity);
@Override
@RestResource(exported = false)
void deleteById(Long aLong);
}
Expected behavior
Because the single entity methods are disabled it should not be added to the docs.
/notifications:
get:
description: get-notification
......
Additional context
The endpoint is considered enabled because the collection methods are added to the item access methods.
Lines 170 to 173 in 60e0512
HttpMethods httpMethodsCollection = resourceMetadata.getSupportedHttpMethods().getMethodsFor(ResourceType.COLLECTION); | |
Set<RequestMethod> requestMethodsCollection = requestMethods.stream().filter(requestMethod -> httpMethodsCollection.contains(HttpMethod.valueOf(requestMethod.toString()))) | |
.collect(Collectors.toSet()); | |
requestMethodsItem.addAll(requestMethodsCollection); |
I lack the insight of why this is done in the first place.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working