Open Sprungwunder opened 6 years ago
Thanks for the quick fix
@Sprungwunder Can you show me what your whole file looks like? It doesn't work for me with Django 1.11.16 and the code below.
django 1.11.16 drf 3.9.0 django-rest-swagger 2.2.0
from django.conf.urls import url
from rest_framework import routers
from rest_framework_swagger.views import get_swagger_view
router = routers.DefaultRouter(trailing_slash=False)
router.register(r"user", views.UserViewSet)
schema_view = get_swagger_view(title="My API")
schema_view.cls.schema = None
urlpatterns = [url(r"^schema/", schema_view)]
urlpatterns += router.urls
@opsdisk
from django.conf import settings
from django.conf.urls.static import static
from django.urls import path, include
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='API', url='/' + settings.BASE_URL)
schema_view.cls.schema = None
urlpatterns = [
path('api/', include('adapter.rest_api.urls')),
path('auth/', include('keycloak_adapter.urls')),
path('swagger-ui/', schema_view)
]
Nothing special so far, api contains the django rest framwork views, auth handles authentication via keycloak, swagger settings only contains a login url and sets USE_SESSION_AUTH to True
Thanks for that, I give it a try.
DjangoRestFramework removed the exclude_from_schema flag to exclude urls from the api schema. This leads to swagger schema view show up as an api endpoint. Instead a "schema = None" must be set for View classes to exclude from the api endpoints. see https://www.django-rest-framework.org/api-guide/schemas/
quifix for me was to hardcode this like
Versions: django 2.1.2 drf 3.9.0 django-rest-swagger 2.2.0