Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIs are not shown in swagger ui on custom permission class #843

Open
mashahabi15 opened this issue Mar 7, 2023 · 1 comment
Open

APIs are not shown in swagger ui on custom permission class #843

mashahabi15 opened this issue Mar 7, 2023 · 1 comment

Comments

@mashahabi15
Copy link

mashahabi15 commented Mar 7, 2023

Hello.
I have set up drf-yasg on my drf project. I have an issue using login required APIs.
I've wrote a custom permission class called MyCustomPerm which inherits from BasePermission and overrides has_permission method. This method reads authorization header and authenticates it against JWT and sets user phone_number on request, then returns True/False considering the fact that user is authenticated or not.
The problem is that Swagger UI doesn't show the APIs that have this permission class:

    permission_classes = [
        MyCustomPerm,
    ]

(My views are class based)
How can I do that?
Thank you very much.

@shahabbasi
Copy link

Adding public=True to swagger initiation will solve the problem. like below:

    schema_view = get_schema_view(
        openapi.Info(
            title="Sample",
            default_version='v1',
        ),
        url="",
        public=True,
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants