Unable to list all api endpoints in swagger file in django and drf spectacular

35 Views Asked by At

Unable to list all api endpoints in swagger file. API endpoints are working as expected wrt functionalities. I'm using py3 and gunicorn as I need this deployed.

Settings.py of djServer project has all req settings

REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema'  
}


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'drf_spectacular',  
    'corsheaders',
    'djApi',
    'djBookings',
    'sample',
]

#djServer/djServer/urls.py
"""
URL configuration for djServer project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from drf_spectacular.views import(
    SpectacularAPIView,
    SpectacularSwaggerView,
)
from django.contrib import admin
from django.urls import path, include, re_path
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
    path('help/Schema/',SpectacularAPIView.as_view(),name='help-schema'),
    path('help/Docs/',SpectacularSwaggerView.as_view(url_name='help-schema'),name='help-docs'),
    path('sampleApi/', include('sample.urls')),
    path('api/', include('djApi.urls')),
    path('bookings/', include('djBookings.urls')),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

While the project has many djnago apps where url is in this form

# djServer/bookings/urls.py
from django.urls import path
from django.urls import path, include, re_path
from .views import *
urlpatterns = [
    path('testEndpoint/', bookingsTest, name='bookingsTest'),
    path('freeTrial/', freeTrial, name='freeTrial'),
    path('availFreeTrial/<str:booking_id>', availFreeTrial, name='availFreeTrial'),
    # Add more paths as needed
]

Swagger page shows only one endpoint enter image description here

0

There are 0 best solutions below