axnsan12 / drf-yasg

Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
https://drf-yasg.readthedocs.io/en/stable/
Other
3.4k stars 437 forks source link

Blocked methods for URL patterns are still shown #844

Open GGenken opened 1 year ago

GGenken commented 1 year ago

Bug Report

Description

DRF-YASG creates an entry for a blocked method of a URL.

Is this a regression?

No, it is not.

Minimal Reproduction

views.py

class FooView(APIView):
    def get(self, request):
        ...

    def post(self, request):
        ...

urls.py

urlpatterns = [
    ...
    path("foo/", views.FooView.as_view()),  # all methods found in view class allowed, as per default, we need both GET and POST here
    path("foo/bar/", views.FooView.as_view(http_method_names=['get'])),  # only GET allowed
]

Result image

The POST to foo/bar/ (last entry on image - foo_bar_create) should not be shown, as this URL has no POST in list of allowed methods (DRF will return HTTP "405 Method Not Allowed" as it should).

Your Environment

drf-yasg==1.21.5
djangorestframework==3.14.0
Django==4.1.7
yngbossjob commented 1 year ago

hi @GGenken, do you have any work around for this issue? Im also facing this similar issue