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.42k stars 439 forks source link

Importing SwaggerAutoSchema removes the custom DRF parameter DEFAULT_AUTHENTICATION_CLASSES #842

Open hntirgeam opened 1 year ago

hntirgeam commented 1 year ago

Bug Report

Importing SwaggerAutoSchema removes the custom DRF parameter DEFAULT_AUTHENTICATION_CLASSES

Am I missing something?

Description

Importing SwaggerAutoSchema anywhere in the project removes the custom DRF parameter DEFAULT_AUTHENTICATION_CLASSES.

I imported it to overload some behavior that generates docstring.

Is this a regression?

Not sure

Minimal Reproduction

Using custom auth class in the DRF settings

REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": (
        "user.authentication.CustomOAuth2Authentication",
    )
}

Import class anywhere in project code

from drf_yasg.inspectors.view import SwaggerAutoSchema

Inspecting base APIView class in DRF source code (method get_authenticators)

I can clearly trace that before the import there was:

[<class 'user.authentication.CustomOAuth2Authentication'>]

and after the import there are:

[<class 'rest_framework.authentication.SessionAuthentication'>, <class 'rest_framework.authentication.BasicAuthentication'>]

Your Environment

drf-yasg==1.21.5
djangorestframework==3.14.0
Django==3.2